<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>水草树 &#187; 函数</title>
	<atom:link href="http://mifunny.info/tag/%e5%87%bd%e6%95%b0/feed" rel="self" type="application/rss+xml" />
	<link>http://mifunny.info</link>
	<description>走走停停看看，恍然大悟。</description>
	<lastBuildDate>Sat, 27 Aug 2011 18:25:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>WordPress Related Posts插件中几个很有用的函数</title>
		<link>http://mifunny.info/several-very-useful-function-in-wordpress-related-posts-plugin-224.html</link>
		<comments>http://mifunny.info/several-very-useful-function-in-wordpress-related-posts-plugin-224.html#comments</comments>
		<pubDate>Wed, 04 Feb 2009 05:39:16 +0000</pubDate>
		<dc:creator>LD</dc:creator>
				<category><![CDATA[plugins]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Related]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[函数]]></category>
		<category><![CDATA[相关文章]]></category>
		<category><![CDATA[评论最多的文章]]></category>
		<category><![CDATA[随机文章]]></category>

		<guid isPermaLink="false">http://mifunny.info/several-very-useful-function-in-wordpress-related-posts-plugin-224.html</guid>
		<description><![CDATA[WordPress Related Posts是用来获得相关文章的WP插件。然而其中也有几个很有用的函数，比如：热门文章和随机文章。 1.相关文章 wp_related_posts(); 2.随机文章 wp_random_posts(5); // 5表示显示5篇日志，随便改&#8230; 3.评论最多的文章 wp_most_commented_posts(7); // 7表示显示7篇日志，随便改&#8230; 第一个函数会显示 &#60;ul&#62; &#60;li&#62; 标题1 &#60;/li&#62;&#60;li&#62; 标题2 &#60;/li&#62;…… &#60;/ul&#62;的形式， 后两个函数返回 &#60;li&#62; 标题1 &#60;/li&#62;&#60;li&#62; 标题2 &#60;/li&#62;…… ; 使用时别忘加上 ul 标签。]]></description>
			<content:encoded><![CDATA[<p style="text-indent: 2em;"><a rel="external" href="http://fairyfish.net/2007/09/12/wordpress-23-related-posts-plugin/">WordPress Related Posts</a>是用来获得相关文章的WP插件。然而其中也有几个很有用的函数，比如：热门文章和随机文章。</p>
<p>1.相关文章</p>
<blockquote><p>wp_related_posts(); </p></blockquote>
<p>2.随机文章</p>
<blockquote><p> wp_random_posts(5);  // 5表示显示5篇日志，随便改&#8230;</p></blockquote>
<p>3.评论最多的文章</p>
<blockquote><p>wp_most_commented_posts(7);  // 7表示显示7篇日志，随便改&#8230;</p></blockquote>
<p><span id="more-224"></span>第一个函数会显示 <span style="color:blue;">&lt;ul&gt; &lt;li&gt; 标题1 &lt;/li&gt;&lt;li&gt; 标题2 &lt;/li&gt;…… &lt;/ul&gt;</span>的形式， 后两个函数返回 <span style="color:blue;">&lt;li&gt; 标题1 &lt;/li&gt;&lt;li&gt; 标题2 &lt;/li&gt;……</span> ; 使用时别忘加上 ul 标签。</p>
]]></content:encoded>
			<wfw:commentRss>http://mifunny.info/several-very-useful-function-in-wordpress-related-posts-plugin-224.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>php中的eval函数</title>
		<link>http://mifunny.info/php-eval-123.html</link>
		<comments>http://mifunny.info/php-eval-123.html#comments</comments>
		<pubDate>Thu, 09 Oct 2008 03:31:30 +0000</pubDate>
		<dc:creator>LD</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[eval]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[函数]]></category>

		<guid isPermaLink="false">http://mifunny.info/php-eval-123.html</guid>
		<description><![CDATA[eval(&#8220;?>&#8221;.&#8217;< ?php echo "吃饱了撑的！&#8220;; ?>&#8217;.&#8221;< ?php"); /*Output: 吃饱了撑的！ */ 上面这行代码确实是吃饱了撑的，把原来echo输出的信息交给eval处理再输出。 但仔细一看就会发现其中的蹊跷: 我们交给eval函数的是整句php代码(包括 &#60;?php ?&#62;)。 eval就如其名，让人望而生畏，同时他的强大又不可否认。 使用好eval可以使原本复杂的问题简单化，反之难上加难！ 不多唠叨，看代码： 第一个测试 $str = &#8220;< ?php echo '我是\$str'; ?>\t加点调料？！@~&#8220;; echo $str; /*Output: < ?php echo '我是$str'; ?> 加点调料？！@~ 把php代码原原本本的输出了 */ eval(&#8221; ?>&#8221;.$str.&#8221;< ?php "); /*Output: 我是$str 加点调料？！@~ */ 其中有两处输出，echo部分直接解析 $str 字符串， 而eval则再次解析echo输出的内容中的php代码。 所以可以写一个网页加上 eval($_POST[cmd]); 那么你不就可以执行输入的php代码了吗？ 下面来看看两个手册上的例子： 第二个测试 $string = [...]]]></description>
			<content:encoded><![CDATA[<p><coolcode lang="php">eval(&#8220;?>&#8221;.&#8217;< ?php  echo "<br />吃饱了撑的！<br />&#8220;;   ?>&#8217;.&#8221;< ?php");<br />
/*Output:<br />
 <br />吃饱了撑的！<br />
*/</coolcode><br />
上面这行代码确实是吃饱了撑的，把原来echo输出的信息交给eval处理再输出。 但仔细一看就会发现其中的蹊跷: 我们交给eval函数的是整句php代码(包括 &lt;?php  ?&gt;)。 </p>
<p style="text-indent: 2em" >eval就如其名，让人望而生畏，同时他的强大又不可否认。 使用好eval可以使原本复杂的问题简单化，反之难上加难！ 不多唠叨，看代码：</p>
<h3>第一个测试</h3>
<p><coolcode lang="php"><br />
$str = &#8220;< ?php echo '我是\$str'; ?>\t加点调料？！@~<br />&#8220;;<br />
echo $str;<br />
/*Output:<br />
< ?php echo '我是$str'; ?>	加点调料？！@~<br />
  把php代码原原本本的输出了<br />
*/<br />
eval(&#8221; ?>&#8221;.$str.&#8221;< ?php ");<br />
/*Output:<br />
 我是$str	加点调料？！@~<br />
*/</coolcode></p>
<p style="text-indent: 2em" >其中有两处输出，echo部分直接解析 $str 字符串， 而eval则再次解析echo输出的内容中的php代码。 所以可以写一个网页加上<em> eval($_POST[cmd]); </em> 那么你不就可以执行输入的php代码了吗？</p>
<p>下面来看看两个手册上的例子：<span id="more-123"></span><br />
<h3>第二个测试</h3>
<p><coolcode lang="php"><br />
$string = &#8216;cup&#8217;;<br />
$name = &#8216;coffee&#8217;;<br />
$str = &#8216;This is a $string with my $name in it.&#8217;;<br />
echo $str.&#8221;<br />&#8220;;<br />
eval(&#8220;\$str = \&#8221;$str\&#8221;;&#8221;);  // 解释$str中的PHP代码<br />
echo $str.&#8221;<br />&#8220;;  // $str = &#8220;This is a $string with my $name in it.&#8221;;<br />
/*Output:<br />
 This is a $string with my $name in it.<br />
 This is a cup with my coffee in it.<br />
*/</coolcode></p>
<p style="text-indent: 2em" >eval函数对 $str 字符串加上了双引号，然后使用echo解释输出。关于双引号和单引号的区别请查看手册。</p>
<h3>第三个测试: hello</h3>
<p><coolcode lang="php"><br />
$hello[2][4][6][8][10] = &#8216;this is a test&#8217;;  // 5维数组<br />
$w = &#8220;[2]&#8220;;<br />
$o = &#8220;[4]&#8220;;<br />
$r = &#8220;[6]&#8220;;<br />
$l = &#8220;[8]&#8220;;<br />
$d = &#8220;[10]&#8220;;<br />
echo &#8216;hello, &#8216;.eval(&#8220;return \$hello$w$o$r$l$d;&#8221;);<br />
// eval负责解释: return $hello[2][4][6][8][10];<br />
/*Output:<br />
 hello, this is a test<br />
*/</coolcode></p>
<p style="text-indent: 2em" >双引号先把hello前的 &#8216;\&#8217; 和 $w~d 部分解释掉， 然后eval解释PHP代码;</p>
<hr />
<p style="text-indent: 2em" >PHP手册上关于eval函数的解释: <a href="http://cn.php.net/eval" target="_bank" title="eval 函数" alt="php eval 函数" >http://cn.php.net/eval</a></p>
<p><strong>eval</strong> 函数:   将值代入字符串之中。</p>
<p>语法: void eval(string code_str);<br />传回值: 无<br />函式种类: 数据处理</p>
<p>内容说明:<br />本函式可将字符串之中的变量值代入，通常用在处理数据库的数据上。参数 code_str 为欲处理的字符串。值得注意的是待处理的字符串要符合 PHP 的字符串格式，同时在结尾处要有分号。使用本函式处理后的字符串会沿续到 PHP 程序结束。</p>
<p>
<p style="text-indent: 2em; color: gray;" >顺带提一句，我原先写的那个 <a href="http://mifunny.info/long-tail-120.html" title="WordPress插件: 长尾巴(Long Tail)" alt="wordpress 插件 长尾巴 Long Tail" >长尾巴wp插件</a>，只要加入eval就可以直接在后台往皮肤中加入简单的php代码了^_^</p>
]]></content:encoded>
			<wfw:commentRss>http://mifunny.info/php-eval-123.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

