<?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://www.laruence.com/category/notes/feed" rel="self" type="application/rss+xml" />
	<link>http://www.laruence.com</link>
	<description>PHP语言, PHP扩展, Zend引擎相关的研究,技术,新闻分享 - 左手代码 右手诗</description>
	<lastBuildDate>Wed, 08 Feb 2012 05:12:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>我们什么时候应该使用异常?</title>
		<link>http://www.laruence.com/2012/02/02/2515.html</link>
		<comments>http://www.laruence.com/2012/02/02/2515.html#comments</comments>
		<pubDate>Thu, 02 Feb 2012 03:36:06 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[status code]]></category>
		<category><![CDATA[异常]]></category>
		<category><![CDATA[状态码]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2515</guid>
		<description><![CDATA[先说个题外话: 在公司做了俩件事, 是我觉得很有意义的, 第一就是成立了一个PHP邮件组, 第二就是成立了一个Hi群. 目前俩者都有超过500 phpers在里面.  我一直认为, 构建一个交流平台, 让同学们能顺畅, 简单的沟通, 是营造积极的技术学习氛围的基础和前提. 让每个人的问题不会成为别人的问题, 则是最直接的利益.
 
   昨天, 有同事在邮件组提了个问题:
<blockquote>
PHP应该什么时候使用 Exception ？ 它的性能如何？
</blockquote>

  这个问题也算是一个久经争论的经典问题了.  我谈谈我的个人看法.
]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2012/02/02/2515.html"  title="Permanet Link to 我们什么时候应该使用异常?" >http://www.laruence.com/2012/02/02/2515.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
   先说个题外话: 在公司做了俩件事, 是我觉得很有意义的, 第一就是成立了一个PHP邮件组, 第二就是成立了一个Hi群. 目前俩者都有超过500 phpers在里面.  我一直认为, 构建一个交流平台, 让同学们能顺畅, 简单的沟通, 是营造积极的技术学习氛围的基础和前提. 让每个人的问题不会成为别人的问题, 则是最直接的利益. (后记: 不少人都问邮件组地址, 实在不好意思, 这个邮件组是公司内部的邮件组, Hi也是公司内部的. 谢谢)</p>
<p>   昨天, 有同事在邮件组提了个问题:</p>
<blockquote><p>
PHP应该什么时候使用 Exception ？ 它的性能如何？
</p></blockquote>
<p>  这个问题也算是一个久经争论的经典问题了.  我谈谈我的个人看法.</p>
<p>  异常与之对应的错误码(或者状态码),  到底各自有什么优点, 缺点, 我们应该怎么使用呢? </p>
<h3>错误码</h3>
<p>  首先来说, 异常机制是在错误码机制之后才出现的, 那么根据进化论, 异常自然是避免了错误码机制的一些不足. 这些不足包括.</p>
<h4>1. 错误信息不丰富</h4>
<p>   函数, 只能有一个返回值(当然, Lua可以返回多个, 但其实也相当于在PHP中返回一个数组),  我们见过最多的函数说明就是: 成功时候返回***, 错误的时候返回FALSE, 然而一个函数出错我原因可能有多种, 出错的种类更有多种. 一个简单的FALSE, 并不能把具体的错误信息告诉调用者. </p>
<p>   于是, 我们也就见过一些, 这样的函数说明: 如果返回值大于0, 则表示成功的状态码,  如果返回值小于0, 则表示出错的状态码. </p>
<p>   然而, 这个要求函数是返回整形(或者数字),  对于一些其他函数, 我们并不能通过0, >0,  <0来判别, 并且, 即使通过这样的方式, 我们还需要用返回的错误码和一些预定义宏(或者调用类似strerror())来获取具体的, 可读的错误信息.</p>
<p>   于是, 就有一些函数使用全局的错误码, 和错误信息, 来保存具体的错误信息, 这个时候我们就看到这样的函数描述: 成功返回***, 出错的时候返回FALSE, 错误代码保存在全局变量$errno中(至少大多数Linux库函数是这样描述的, 呵呵).</p>
<p>   Okey, 这样的方式确实可以工作, 但是, 是不是觉得, 很丑陋呢?</p>
<h4>2. 加入错误状态码可能需要改变函数签名</h4>
<p>   假设, 你编写了一个函数,  这个函数很简单, 很简单, 你认为他绝对不会出错, 于是你申明为(用C语言为例, PHP没有返回类型提示):</p>
<pre name="code"  class="sh_c"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
void dummy() {
}
</pre>
<p>  但是后来你慢慢修改了这个函数, 给了它更多的功能, 此时这个函数可能会失败了. 而你现在根本无法为这个函数, 加入错误返回码了.  </p>
<p>  也许有人说PHP没有返回值类型限制一说, 但是想想PHP的构造函数, 构造函数是没有返回值的, 当发生错误的时候, 如果你不使用异常, 我想你只能选择die, 或者使用2中的方法来错误继续执行了.</p>
<p>  另外, 在一个良好的软件系统中, 返回类型其实也是约定俗成的,  当所有的使用的函数的地方, 都没有检查返回值的时候, 你还是无法为这个函数加入错误返回码.</p>
<h4>3. 错误状态码可能会被忽略</h4>
<p>   当你的一个函数, 出错了, 返回了错误状态码, 而调用方并没有检测这个返回值,  会发生什么情况呢?  -_#.   令一方面,  处处检测返回状态码, 会造成代码非常的,,ugly:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
  if (!call1()) {
      die();
  }

  if (call2() != SUCCESS) {
     die();
  }

  if (call3() &lt; 0) {
      $msg = error_get_last();
      die($msg[&quot;message&quot;]);
  }
</pre>
<h3>异常机制</h3>
<p>  那么现在我们来看看异常机制, 如果我们采用异常机制,  上面的代码可以写作:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
try {
   call1();
   call2();
   call3();
} catch (Exception $e) {
   die($e-&gt;getMessage());
}
</pre>
<p>   更方便的, 如果你的代码只是中间层, 你的调用方会负责处理错误的话, 你甚至可以简单的写作:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
function myFunc() {
   call1();
   call2();
   call3();
}
</pre>
<p>   而一个异常对象, 可以包含更丰富的错误信息, 比如错误信息, 错误码, 错误的行数, 文件, 甚至出错上下文, 等等, 避免的&#8221;1.错误信息不丰富&#8221;的不足.</p>
<p>   我们也可以为一个返回void类型的函数增加异常,  而不改变他的函数签名, 也就不会有上面说的&#8221;2.加入错误状态码可能需要改变函数签名&#8221;.  对于PHP来说, 如果我们新加入的错误没有被捕捉, 也不用担心, 会明显的出错的. 也就不会发生上面所说的&#8221;3. 错误状态码可能会被忽略&#8221;的情况.</p>
<p>   然而, 也有一些反对使用异常的声音:</p>
<h4> 1. 性能</h4>
<p>    正如文章开头提问中的: &#8220;它的性能如何？&#8221;,  异常机制确实要比返回状态码的方式昂贵一些, 对于C++来说, 在异常发生的时候, 还要发生堆栈解退(对于PHP来说, 没有这个逻辑, 具体的大家可以参看我之间写的一篇文章:<a href="http://www.laruence.com/2010/08/03/1697.html" > 深入理解PHP原理之异常机制</a>). </p>
<p>    性能和方便, 往往是一个矛盾体,  我只能说, 你需要权衡,  如果你写的是一个小的模块, 并且它的生命期可能很短, 也不需要什么特殊的设计模式, 那我觉得你可以不用异常.</p>
<p>    而如果你在为一个庞大的软件做开发, 我想你更应该看重的, 应该是, 它的可扩展性, 可维护性.</p>
<h4>2. 太多可能的Uncaught Exception</h4>
<p>     如果, 你调用了一个可能发生异常的函数, 但是却没有捕获这个异常, okey, Fatal Error了,  所以让我们的代码看起来:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
try {
} catch () {
}
....

try {
} catch () {
}
....
try {
} catch () {
}
</pre>
<p>     然而, 这个是可以经过良好设计避免的, 比如我在设计<a href="http://pecl.php.net/package/yaf" >Yaf</a>的时候, 就提供了全局异常处理, 也就是类似于, 你在最最顶层, 加上了一个try catch,  所有的异常错误逻辑都加到这个里面, 你也可以很方面的把你自己的异常加进去.  </p>
<h3>结论</h3>
<p>     经常有人批评我是俩面派,  呵呵, 但是在大家了解了上面的利弊以后, 是否也会和我一样认为: 这个事情没有定论呢? 一切从实际出发. <img src="http://www.laruence.com/wp-includes/images/smilies/icon_smile.gif"  alt=":)"  class="wp-smiley" /> </p>
<p>     说了这么多, 算是抛砖引玉, 欢迎补充, 交流: <a href="http://www.laruence.com" >here</a> or <a href="http://weibo.com/laruence" >here</a>.<br/>
   <script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_c.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script></p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/02</a>, <a href="http://www.shibeike.net"  rel="external nofollow"  class="url" >treesky</a> writes: 前排留名啊。学习。HI群有点麻烦，能不能让我们也加入邮件列表啊。</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/02</a>, darasion writes: 顶。
这个问题是我问的。

多谢，看完这文章明白多了。</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/02</a>, lin writes: 能不能加入邮件列表和HI群</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/02</a>, benson writes: 请问，作为一个production，异常处理的使用是为了在产品发生错误的时候能更好的提示用户，或者通知开发者，是这样理解吗？</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/02</a>, <a href="http://blog.chedushi.com"  rel="external nofollow"  class="url" >岭南六少</a> writes: 哈哈，现在用hi的人貌似不是很多啊</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/02</a>, <a href="http://www.kaiiak.com"  rel="external nofollow"  class="url" >xiaokaizi</a> writes: class xx{
    public $box[2] = 'fds';

    public function echso() {
        // ...
    }
}  这样定义类为什么报语法错误？

在zend_language_parser.c里，变量名是不允许带[]的，估计在词法分析那一步把$box[2]分割成了一个变量名，fds是值，到语法分析这步就出错了。
如果是这样原因。问题是为什么要在类的成员变量中这样分割，而普通变量缺不呢?</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/02</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @xiaokaizi class的属性声明必须使用常数, 见:http://www.php.net/manual/en/language.oop5.properties.php 

这个常数, 同时对值, 和, 名有效. :)</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/02</a>, oboodo writes: 求hi群号，惠兄！</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/02</a>, <a href="http://blankyao.com"  rel="external nofollow"  class="url" >blankyao</a> writes: 前几天遇到一个问题，类似下面的操作
stream1.close();
stream2.close();
stream3.close();
...

这几行代码都有可能抛出异常，但是抛出异常后也得保证后面的代码继续执行，所以就不能在外面搞一个try catch，所以现在是每一行都加一个tray catch，但是感觉比较ugly，有啥好的建议不？</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/04</a>, phper writes: 求hi群号</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/06</a>, <a href="http://blog.iterse.com"  rel="external nofollow"  class="url" >Iterse's blog</a> writes: 支持下，两边都做分析了，哈哈。奢望一下哦，希望能加入您的php邮件组。</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/06</a>, <a href="http://www.w3hacker.com"  rel="external nofollow"  class="url" >万维网黑客联盟</a> writes: 万维网黑客联盟 求友情链接</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/07</a>, likemeng writes: 希望能加入邮件组！</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/07</a>, xiatian writes: 我一直有个困惑,通常情况下某个函数或方法只返回true和false,在特定条件下需要抛出一个异常(当然也就没有返回值了),当抛出异常后,原先调用这个函数或者方法的流程自然就没有继续执行了,程序通常会由set_exception_handler定义的处理方式去处理异常了,而此前调用的流程就被阻断,而我又不想对它单独定义try/catch.
演示伪代码:
function is_ok(xxx){
    if (not xxx){throw new Exception('xxx is not ok')}
    return true OR false;
}

...
if (is_ok())
{
    :)
}
else
{
    :(
}

//抛出异常后上面的就不会执行了,有没有不在这里try/catch的解决办法,我想总是用set_exception_handler去处理所有异常</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/07</a>, <a href="http://iptohost.net"  rel="external nofollow"  class="url" >Peter</a> writes: 博主你平时用的zend是上面的颜色主题吗？？</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/07</a>, <a href="http://pdfdog.org"  rel="external nofollow"  class="url" >pdfdog</a> writes: 博主你的zend主题叫什么啊，好顺眼，麻烦给偶百度下啦~</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/08</a>, <a href="http://china.com"  rel="external nofollow"  class="url" >dulidong</a> writes: 支持下laruence,希望能加入邮件组</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/08</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @pdfdog 这是vim, 不过好像zend ide也有类似的配色方案, 只是我不知道 :)</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/08</a>, <a href="http://waibo.net/"  rel="external nofollow"  class="url" >Rhythm</a> writes: 请问，这个vim的配色方案叫什么名字？</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/08</a>, <a href="http://waibo.net/"  rel="external nofollow"  class="url" >Rhythm</a> writes: 能否发起，成立一个中国PHP的邮件组。</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/08</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >laruence</a> writes: @Rhythm 好注意, 我试着问问Rasmus. 另外这个配色方案好像叫做ir_black..</li><li><a href="http://www.laruence.com/2012/02/02/2515.html" >2012/02/09</a>, <a href="http://lidashuang.sinaapp.com/?p=58"  rel="external nofollow"  class="url" >lidashuang &raquo; 我们什么时候应该使用异常?</a> writes: [...] 本文地址: http://www.laruence.com/2012/02/02/2515.html [...]</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li><li><a href="http://www.laruence.com/2012/01/11/2482.html"  title="PHP的历史" >PHP的历史</a></li><li><a href="http://www.laruence.com/2012/01/10/2469.html"  title="如何设置一个严格30分钟过期的Session" >如何设置一个严格30分钟过期的Session</a></li><li><a href="http://www.laruence.com/2012/01/07/2453.html"  title="2012年1月全球www网站技术报告" >2012年1月全球www网站技术报告</a></li><li><a href="http://www.laruence.com/2011/12/30/2440.html"  title="PHP5.2.*防止Hash冲突拒绝服务攻击的Patch" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch</a></li><li><a href="http://www.laruence.com/2011/12/30/2435.html"  title="PHP数组的Hash冲突实例" >PHP数组的Hash冲突实例</a></li><li><a href="http://www.laruence.com/2011/12/29/2412.html"  title="通过构造Hash冲突实现各种语言的拒绝服务攻击" >通过构造Hash冲突实现各种语言的拒绝服务攻击</a></li><li><a href="http://www.laruence.com/2011/12/06/2381.html"  title="更简单的重现PHP Core的调用栈" >更简单的重现PHP Core的调用栈</a></li><li><a href="http://www.laruence.com/2011/11/18/2305.html"  title="GBK编码PHP脚本导致语法错误(Zend Multibyte)" >GBK编码PHP脚本导致语法错误(Zend Multibyte)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2012/02/02/2515.html/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>大家新年好~</title>
		<link>http://www.laruence.com/2012/01/24/2494.html</link>
		<comments>http://www.laruence.com/2012/01/24/2494.html#comments</comments>
		<pubDate>Tue, 24 Jan 2012 03:11:13 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[拜年]]></category>
		<category><![CDATA[龙年]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2494</guid>
		<description><![CDATA[<p>
   写博客3年了, 也借此认识了不少朋友. 

   到今天, 博客的google订阅数3,870,  那就祝愿所有订阅我博客的同学们, 身体永远健康, 所有不经意来到我博客的同学们, 身体比较健康!!

   龙年大吉. 

thanks
</p>]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2012/01/24/2494.html"  title="Permanet Link to 大家新年好~" >http://www.laruence.com/2012/01/24/2494.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
   写博客3年了, 也借此认识了不少朋友. </p>
<p>   到今天, 博客的google订阅数3,870,  那就祝愿所有订阅我博客的同学们, 身体永远健康, 所有不经意来到我博客的同学们, 身体比较健康!! 嘿嘿.<br/>
<div id="attachment_2499"  class="wp-caption aligncenter"  style="width: 371px" ><a href="http://laruence-wordpress.stor.sinaapp.com/uploads/0fc8b37f0fcb49688544f969.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/0fc8b37f0fcb49688544f969.png"  alt=""  title="0fc8b37f0fcb49688544f969"  width="361"  height="543"  class="size-full wp-image-2499" /></a><p class="wp-caption-text" >新年快乐</p></div><br/>
   龙年大吉. </p>
<p>thanks</p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/24</a>, <a href="http://www.jymoz.com"  rel="external nofollow"  class="url" >Lotte</a> writes: 3870分之一啊 哈哈</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/24</a>, <a href="http://veapon.com"  rel="external nofollow"  class="url" >veapon</a> writes: 这图很有内涵...
恭喜发财，，</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/24</a>, <a href="http://blog.francistm.com"  rel="external nofollow"  class="url" >francis</a> writes: 新年快乐，恭喜发财啊～</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/26</a>, <a href="http://blog.greycode.cn"  rel="external nofollow"  class="url" >stvenx</a> writes: 新年快乐！</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/27</a>, joey writes: 新年好~~配图很牛X~</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/28</a>, <a href="http://solupro.sinaapp.com"  rel="external nofollow"  class="url" >solu</a> writes: 新年快乐！
“比较”亮了！</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/29</a>, <a href="http://rossobe.com"  rel="external nofollow"  class="url" >Amaranth</a> writes: "比较健康" 好无语</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/30</a>, <a href="http://digdeeply.info"  rel="external nofollow"  class="url" >DigDeeply</a> writes: 我是身体永远健康的，，哈哈。</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/30</a>, <a href="http://blog.chedushi.com"  rel="external nofollow"  class="url" >岭南六少</a> writes: 向鸟哥学习</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/30</a>, 谢飞 writes: 新年快乐,恭喜发财</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/01/31</a>, litton writes: 新年好</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/02/01</a>, Joe writes: 为了身体永远健康,赶紧订阅了一下!-_-</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/02/02</a>, oboodo writes: 比较健康…… 尴尬了……</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/02/05</a>, <a href="http://www.sklinux.com"  rel="external nofollow"  class="url" >sk</a> writes: 同样的祝福你也送给你！</li><li><a href="http://www.laruence.com/2012/01/24/2494.html" >2012/02/05</a>, <a href="http://www.pcyoyo.com"  rel="external nofollow"  class="url" >localtest</a> writes: 龙年大吉！</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Random Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2009/08/23/1065.html"  title="深入理解PHP之数组(遍历顺序)" >深入理解PHP之数组(遍历顺序)</a></li><li><a href="http://www.laruence.com/2010/05/18/1482.html"  title="深入理解PHP原理之对象(一)" >深入理解PHP原理之对象(一)</a></li><li><a href="http://www.laruence.com/2008/11/07/586.html"  title="深入理解PHP原理之文件上传" >深入理解PHP原理之文件上传</a></li><li><a href="http://www.laruence.com/2011/11/05/2262.html"  title="Yaf的性能对比测试" >Yaf的性能对比测试</a></li><li><a href="http://www.laruence.com/2008/04/16/98.html"  title="使用fscok实现异步调用PHP " >使用fscok实现异步调用PHP </a></li><li><a href="http://www.laruence.com/2010/12/14/1816.html"  title="Compilation failed: support for \P, \p, and \X has not been compiled" >Compilation failed: support for \P, \p, and \X has not been compiled</a></li><li><a href="http://www.laruence.com/2008/09/04/498.html"  title="PHP4中模拟类的析构函数" >PHP4中模拟类的析构函数</a></li><li><a href="http://www.laruence.com/2011/07/14/2115.html"  title="Zend引擎的优化" >Zend引擎的优化</a></li><li><a href="http://www.laruence.com/2009/07/23/994.html"  title="PHP中的Hash算法" >PHP中的Hash算法</a></li><li><a href="http://www.laruence.com/2009/07/27/1020.html"  title="深入理解PHP原理之错误抑制与内嵌HTML" >深入理解PHP原理之错误抑制与内嵌HTML</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2012/01/24/2494.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>PHP的历史</title>
		<link>http://www.laruence.com/2012/01/11/2482.html</link>
		<comments>http://www.laruence.com/2012/01/11/2482.html#comments</comments>
		<pubDate>Wed, 11 Jan 2012 03:14:30 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[转载]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP 3.0]]></category>
		<category><![CDATA[PHP 4]]></category>
		<category><![CDATA[PHP/FI]]></category>
		<category><![CDATA[历史]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2482</guid>
		<description><![CDATA[了解下PHP的历史, 有助于更加深刻的了解PHP发展到今天的轨迹,  下面的文字都是从<a href="http://www.php.net/manual/zh/history.php">» PHP手册</a>中转载过来的.

PHP 在过去的几年里走过了漫长的道路。成长为处理 web 的最卓越的语言并非易事。如果对 PHP 如何发展到今天很感兴趣，那么请继续读下去吧。以前的 PHP 发行版可以在 <a herf="http://museum.php.net/">» PHP 博物馆</a>找到。]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>本文地址: <a href="http://www.laruence.com/2012/01/11/2482.html"  title="Permanet Link to PHP的历史" >http://www.laruence.com/2012/01/11/2482.html</a></li>
<li>文章转自: <a href="http://www.php.net/manual/zh/history.php" >PHP 及其相关工程的历史</a></li>
</ul></div>
<p>了解下PHP的历史, 有助于更加深刻的了解PHP发展到今天的轨迹,  下面的文字都是从<a href="http://www.php.net/manual/zh/history.php" >» PHP手册</a>中转载过来的.</p>
<p>PHP 在过去的几年里走过了漫长的道路。成长为处理 web 的最卓越的语言并非易事。如果对 PHP 如何发展到今天很感兴趣，那么请继续读下去吧。以前的 PHP 发行版可以在 <a herf="http://museum.php.net/" >» PHP 博物馆</a>找到。</p>
<h3>PHP/FI</h3>
<p>PHP 继承自一个老的工程，名叫 PHP/FI。PHP/FI 在 1995 年由 Rasmus Lerdorf 创建，最初只是一套简单的 Perl 脚本，用来跟踪访问他主页的人们的信息。它给这一套脚本取名为“Personal Home Page Tools”。随着更多功能需求的增加，Rasmus 写了一个更大的 C 语言的实现，它可以访问数据库，可以让用户开发简单的动态 Web 程序。Rasmus » 发布了 PHP/FI 的源代码，以便每个人都可以使用它，同时大家也可以修正它的 Bug 并且改进它的源代码。</p>
<p>PHP/FI，一个专为个人主页／表单提供解释程序的程序，已经包含了今天 PHP 的一些基本功能。它有着 Perl 样式的变量，自动解释表单变量，并可以嵌入 HTML。语法本身与 Perl 很相似，但是它很有限，很简单，还稍微有些不协调。</p>
<p>到1997年，PHP/FI 2.0，也就是它的 C 语言实现的第二版在全世界已经有几千个用户（估计）和大约 50,000 个域名安装，大约是 Internet 所有域名的 1%。但是那时只有几个人在为该工程撰写少量当代码，它仍然只是一个人的工程。</p>
<p>PHP/FI 2.0 在经历了数个 beta 版本的发布后于 1997 年 11 月发布了官方正式版本。不久，PHP 3.0 的第一个 alpha 版本的发布，PHP 从此走向了成功。</p>
<h3>PHP 3</h3>
<p>PHP 3.0 是类似于当今 PHP 语法结构的第一个版本。Andi Gutmans 和 Zeev Suraski 在为一所大学的项目中开发电子商务程序时发现 PHP/FI 2.0 功能明显不足，于是他们重写了代码。这就是 PHP 3.0。经过Andi，Rasmus 和 Zeev 一系列的努力，考虑到 PHP/FI 已存在的用户群，他们决定联合发布 PHP 3.0 作为 PHP/FI 2.0 的官方后继版本。而 PHP/FI 2.0 的进一步开发几乎终止了。</p>
<p>PHP 3.0 的一个最强大的功能是它的可扩展性。除了给最终用户提供数据库、协议和 API 的基础结构，它的可扩展性还吸引了大量的开发人员加入并提交新的模块。后来证实，这是 PHP 3.0 取得巨大成功的关键。PHP 3.0 中的其它关键功能包括面向对象的支持和更强大和协调的语法结构。</p>
<p>这个全新的语言伴随着一个新的名称发布。它从 PHP/FI 2.0 的名称中移去了暗含“本语言只限于个人使用”的部分。它被命名为简单的缩写“PHP”。这是一种递归的缩写，它的全称是——PHP: Hypertext Preprocessor。</p>
<p>1998 年末，PHP 的安装人数几近 10,000，有大约 100,000 个网站报告他们使用了 PHP。在 PHP 3.0 的顶峰，Internet 上 10% 的 web 服务器上都安装了它。</p>
<p>约九个月的公开测试后，官方于 1998 年 6 月正式发布 PHP 3.0。</p>
<h3>PHP 4</h3>
<p>1998 年的冬天，PHP 3.0 官方发布不久，Andi Gutmans 和 Zeev Suraski 开始重新编写 PHP 代码。设计目标是增强复杂程序运行时的性能和 PHP 自身代码的模块性。PHP 3.0 的新功能和广泛的第三方数据库、API的支持使得这样程序的编写成为可能，但是 PHP 3.0 没有高效处理如此复杂程序的能力。</p>
<p>新的被称为“Zend Engine”（这是 Zeev 和 Andi 的缩写）的引擎，成功的实现了设计目标，并在 1999 年中期首次引入 PHP。基于该引擎并结合了更多新功能的 PHP 4.0，在 PHP 3.0 发布两年后，于2000年5月发布了官方正式版本。除了更高的性能以外，PHP 4.0 还包含了其它一些关键功能，比如：支持更多的 web 服务器；HTTP Sessions 支持；输出缓冲；更安全的处理用户输入的方法；一些新的语言结构。</p>
<p>今天，已经有 10,000 名开发人员（估计）和几百万网站报告已安装了 PHP，占整个 Internet 域名的 20%。</p>
<p>PHP 的开发小组有很多优秀的开发人员，同时还有大量的优秀人才在进行 PHP 相关工程的开发工作，如 PEAR 和 PHP 文档的工程。</p>
<h3>PHP 5</h3>
<p>PHP 5 在长时间的开发及多个预发布版本后，于 2004 年 7 月发布正式版本。它的核心是 Zend 引擎 2 代，引入了新的对象模型和大量新功能。</p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2012/01/11/2482.html" >2012/01/11</a>, <a href="http://hi.baidu.com/higkoo"  rel="external nofollow"  class="url" >higkoo</a> writes: 好事多磨，愿PHP越来越好，越来越强！</li><li><a href="http://www.laruence.com/2012/01/11/2482.html" >2012/01/11</a>, <a href="http://deloz.net"  rel="external nofollow"  class="url" >Deloz</a> writes: C是很多语言的基础呀.</li><li><a href="http://www.laruence.com/2012/01/11/2482.html" >2012/01/11</a>, <a href="http://waibo.net/"  rel="external nofollow"  class="url" >Rhythm</a> writes: 总是能多些思考，感谢。</li><li><a href="http://www.laruence.com/2012/01/11/2482.html" >2012/01/12</a>, <a href="http://blog.netoearth.com/html/201201/php%e7%9a%84%e5%8e%86%e5%8f%b2.htm"  rel="external nofollow"  class="url" >PHP的历史</a> writes: [...] 本文地址: http://www.laruence.com/2012/01/11/2482.html [...]</li><li><a href="http://www.laruence.com/2012/01/11/2482.html" >2012/01/13</a>, harveyzh writes: 为什么创造php的作者 Rasmus Lerdorf 离开了？</li><li><a href="http://www.laruence.com/2012/01/11/2482.html" >2012/01/17</a>, <a href="http://gnroed@gmail.com"  rel="external nofollow"  class="url" >nroe</a> writes: 我们在更新到　５.３.９　版本后发现，出现很多　“no buffer space available”　的错误提示，导致　TCP/IP SOCKET　无法创建，服务无法正常运行。
请问下　5.3.9　在创建　SOCKET　的是否是不是加大了缓冲区？</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/09/19/2148.html"  title="PHP的版本发布历程" >PHP的版本发布历程</a></li><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/02/2515.html"  title="我们什么时候应该使用异常?" >我们什么时候应该使用异常?</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li><li><a href="http://www.laruence.com/2012/01/10/2469.html"  title="如何设置一个严格30分钟过期的Session" >如何设置一个严格30分钟过期的Session</a></li><li><a href="http://www.laruence.com/2012/01/07/2453.html"  title="2012年1月全球www网站技术报告" >2012年1月全球www网站技术报告</a></li><li><a href="http://www.laruence.com/2011/12/30/2440.html"  title="PHP5.2.*防止Hash冲突拒绝服务攻击的Patch" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch</a></li><li><a href="http://www.laruence.com/2011/12/30/2435.html"  title="PHP数组的Hash冲突实例" >PHP数组的Hash冲突实例</a></li><li><a href="http://www.laruence.com/2011/12/29/2412.html"  title="通过构造Hash冲突实现各种语言的拒绝服务攻击" >通过构造Hash冲突实现各种语言的拒绝服务攻击</a></li><li><a href="http://www.laruence.com/2011/12/06/2381.html"  title="更简单的重现PHP Core的调用栈" >更简单的重现PHP Core的调用栈</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2012/01/11/2482.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>如何设置一个严格30分钟过期的Session</title>
		<link>http://www.laruence.com/2012/01/10/2469.html</link>
		<comments>http://www.laruence.com/2012/01/10/2469.html#comments</comments>
		<pubDate>Tue, 10 Jan 2012 07:02:17 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[COOKIE]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[过期]]></category>
		<category><![CDATA[面试题]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2469</guid>
		<description><![CDATA[今天在我的微博(<a href="http://t.sina.com.cn/laruence">Laruence</a>)上发出一个问题:
<blockquote>
我在面试的时候, 经常会问一个问题: "如何设置一个30分钟过期的Session?", 大家不要觉得看似简单, 这里面包含的知识挺多, 特别适合考察基本功是否扎实, 谁来回答试试? 呵呵
</blockquote>

   为什么问这个问题呢?  1. 我在Twitter上看到了有人讨论这个<a href="http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes">问题</a>, 2 想起来我经常问这个问题, 所以~~

   在这里, 我来解答下这个题目.]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2012/01/10/2469.html"  title="Permanet Link to 如何设置一个严格30分钟过期的Session" >http://www.laruence.com/2012/01/10/2469.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
    今天在我的微博(<a href="http://t.sina.com.cn/laruence" >Laruence</a>)上发出一个问题:</p>
<blockquote><p>
我在面试的时候, 经常会问一个问题: &#8220;如何设置一个30分钟过期的Session?&#8221;, 大家不要觉得看似简单, 这里面包含的知识挺多, 特别适合考察基本功是否扎实, 谁来回答试试? 呵呵
</p></blockquote>
<p>   为什么问这个问题呢?  1. 我在Twitter上看到了有人讨论这个<a href="http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes" >问题</a>, 2 想起来我经常问这个问题, 所以~~</p>
<p>   在这里, 我来解答下这个题目.</p>
<h3>第一种回答</h3>
<p>那么, 最常见的一种回答是: 设置Session的过期时间, 也就是<a href="http://www.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime" >session.gc_maxlifetime</a>,  这种回答是不正确的, 原因如下:</p>
<p>   1.  首先, 这个PHP是用一定的概率来运行session的gc的, 也就是session.gc_probability和session.gc_divisor(介绍参看<a href="http://www.laruence.com/2011/03/29/1949.html" > 深入理解PHP原理之Session Gc的一个小概率Notice</a>), 这个默认的值分别是1和100, 也就是有1%的机会, PHP会在一个Session启动时, 运行Session gc. 不能保证到30分钟的时候一定会过期.</p>
<p>   2. 那设置一个大概率的清理机会呢?  还是不妥, 为什么?  因为PHP使用stat Session文件的修改时间来判断是否过期, 如果增大这个概率一来会降低性能, 二来, PHP使用&#8221;一个&#8221;文件来保存和一个会话相关的Session变量, 假设我5分钟前设置了一个a=1的Session变量, 5分钟后又设置了一个b=2的Seesion变量, 那么这个Session文件的修改时间为添加b时刻的时间, 那么a就不能在30分钟的时候, 被清理了. 另外还有下面第三个原因.</p>
<p>   3. PHP默认的(Linux为例), 是使用/tmp 作为Session的默认存储目录, 并且手册中也有如下的描述:</p>
<blockquote><p>
Note: 如果不同的脚本具有不同的 session.gc_maxlifetime 数值但是共享了同一个地方存储会话数据，则具有最小数值的脚本会清理数据。此情况下，与 session.save_path 一起使用本指令。
</p></blockquote>
<p>      也就是说, 如果有俩个应用都没有指定自己独立的save_path, 一个设置了过期时间为2分钟(假设为A), 一个设置为30分钟(假设为B), 那么每次当A的Session gc运行的时候, 就会同时删除属于应用B的Session files.</p>
<p>      所以, 第一种答案是不&#8221;完全严格&#8221;正确的.</p>
<h3>第二种答案</h3>
<p>还有一种常见的答案是: 设置Session ID的载体, Cookie的过期时间, 也就是<a href="http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime" >session.cookie_lifetime</a>.  这种回答也是不正确的, 原因如下:</p>
<p>    这个过期只是Cookie过期,  换个说法这点就考察Cookie和Session的区别, Session过期是服务器过期, 而Cookie过期是客户端(浏览器)来保证的, 即使你设置了Cookie过期, 这个只能保证标准浏览器到期的时候, 不会发送这个Cookie(包含着Session ID), 而如果通过构造请求, 还是可以使用这个Session ID的值.</p>
<h3>第三种答案</h3>
<p>使用memcache, redis等, okey, 这种答案是一种正确答案.  不过, 很显然出题者肯定还会接着问你, 如果只是使用PHP呢?</p>
<h3>第四种答案</h3>
<p>当然, 面试不是为了难道你, 而是为了考察思考的周密性. 在这个过程中我会提示出这些陷阱,  所以一般来说, 符合题意的做法是:</p>
<p>    1. 设置Cookie过期时间30分钟, 并设置Session的lifetime也为30分钟.</p>
<p>    2. 自己为每一个Session值增加Time stamp.</p>
<p>    3. 每次访问之前, 判断时间戳. </p>
<p>最后, 有同学问,  为什么要设置30分钟的过期时间:  这个, 首先这是为了面试, 第二, 实际使用场景的话, 比如30分钟就过期的优惠劵? </p>
<p>thanks <img src="http://www.laruence.com/wp-includes/images/smilies/icon_smile.gif"  alt=":)"  class="wp-smiley" /> </p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/10</a>, peng writes: thanks</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/10</a>, <a href="http://weibo.com/pangee"  rel="external nofollow"  class="url" >pangee</a> writes: 好吧。学习了。</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/10</a>, <a href="http://blog.webfuns.net"  rel="external nofollow"  class="url" >tomheng</a> writes: 应该是stackoverflow吧</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/10</a>, <a href="http://www.cxphp.com"  rel="external nofollow"  class="url" >鑫爷</a> writes: 好东西啊。学习了。。</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/10</a>, <a href="http://www.shibeike.net"  rel="external nofollow"  class="url" >treesky</a> writes: 引用部分的那个歪字体看起来十分费劲。</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/10</a>, heyli writes: 第一回答 php.ini 修改 至于修改那里 不记得要回去查下
第二 要严格的 我会考虑写进数据库</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/10</a>, wclssdn writes: 好吧.. 我的第一反应就是session中存时间戳.. 如果session中变量需要设置过期.. 那就为变量添加时间戳.... 
貌似这个方法最可靠了~~ 
使用内存缓存之类的... 是使用它们替换session存储位置? 
那同样没有设置过期时间的地方... 只能再此基础上封装成类.. 在方法中添加过期时间. 传递给redis.. 而这样.. 就跟添加时间戳没区别了...</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/11</a>, 四不象 writes: 为什么我觉得第一种回答的第一点不成立呢。那个设置是gc，垃圾回收，并非是没被回收的session文件不会过期。PHP的session默认的file引擎在读取session文件前还是会判断文件最后修改时间的，如果超出session.gc_maxlifetime就不会读取这个session文件</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/11</a>, <a href="http://weibo.com/enzohere"  rel="external nofollow"  class="url" >enzo</a> writes: session.gc_maxlifetime既然不能严格控制session的过期时间，这算不算bug？我的愚建是既然有个这样的配置就应该保证这个配置对应的功能能起到确定的作用。</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/12</a>, silentime writes: 实际的应用场景如果需要严格过期的话，应该不会用session机制把？</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/12</a>, <a href="http://blog.byedown.com/topics/489.html"  rel="external nofollow"  class="url" >如何设置一个严格30分钟过期的Session | Just Me</a> writes: [...] 原文地址: http://www.laruence.com/2012/01/10/2469.html [...]</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/01/31</a>, <a href="http://sk80.sinaapp.com/?p=51"  rel="external nofollow"  class="url" >如何设置一个严格30分钟过期的Session | Only WordPress</a> writes: [...] 来源：http://www.laruence.com/2012/01/10/2469.html 第一种回答 [...]</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/02/01</a>, <a href="http://www.tageta.com"  rel="external nofollow"  class="url" >klvoek</a> writes: 第三种答案求深入</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/02/01</a>, <a href="http://www.52sql.com/?p=272"  rel="external nofollow"  class="url" >如何设置一个严格30分钟过期的Session | 迈克</a> writes: [...] 来源：http://www.laruence.com/2012/01/10/2469.html [...]</li><li><a href="http://www.laruence.com/2012/01/10/2469.html" >2012/02/05</a>, <a href="http://www.sklinux.com"  rel="external nofollow"  class="url" >sk</a> writes: 非常好的文章哦，博主加油！</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/03/29/1949.html"  title="深入理解PHP原理之Session Gc的一个小概率Notice" >深入理解PHP原理之Session Gc的一个小概率Notice</a></li><li><a href="http://www.laruence.com/2009/12/05/1172.html"  title="PHP5.2.x + APC的一个bug的定位" >PHP5.2.x + APC的一个bug的定位</a></li><li><a href="http://www.laruence.com/2009/07/13/976.html"  title="PHP Session的一个警告" >PHP Session的一个警告</a></li><li><a href="http://www.laruence.com/2008/04/04/17.html"  title="在PHP Module中获取$_GET/$_POST/$_COOKIE的方法研究" >在PHP Module中获取$_GET/$_POST/$_COOKIE的方法研究</a></li><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/02/2515.html"  title="我们什么时候应该使用异常?" >我们什么时候应该使用异常?</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li><li><a href="http://www.laruence.com/2012/01/11/2482.html"  title="PHP的历史" >PHP的历史</a></li><li><a href="http://www.laruence.com/2012/01/07/2453.html"  title="2012年1月全球www网站技术报告" >2012年1月全球www网站技术报告</a></li><li><a href="http://www.laruence.com/2011/12/30/2440.html"  title="PHP5.2.*防止Hash冲突拒绝服务攻击的Patch" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2012/01/10/2469.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>2012年1月全球www网站技术报告</title>
		<link>http://www.laruence.com/2012/01/07/2453.html</link>
		<comments>http://www.laruence.com/2012/01/07/2453.html#comments</comments>
		<pubDate>Sat, 07 Jan 2012 09:21:15 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[转载]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[排行]]></category>
		<category><![CDATA[统计]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2453</guid>
		<description><![CDATA[ <a href="http://w3techs.com/">W3Techs</a>在2012年1月7日, 发出最新的"全球www网站技术报告".

    该统计基于对全球Alexa排名前100W的www网站做分析而得出.

    统计报告(<a href="http://w3techs.com/technologies/overview/programming_language/all">Usage of server-side programming languages for websites</a>)显示, 相比2011年12月, 使用PHP构建的前100W名中的网站,又增长了约0.1%(30个), PHP占据的份额增长至77.3%, 依旧排名第一.]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>本文地址: <a href="http://www.laruence.com/2012/01/07/2453.html"  title="Permanet Link to 2012年1月全球www网站技术报告" >http://www.laruence.com/2012/01/07/2453.html</a></li>
<li>文章转自: <a href="http://w3techs.com/technologies/overview/programming_language/all" >Usage of server-side programming languages for websites</a></li>
</ul></div>
<p>
    <a href="http://w3techs.com/" >W3Techs</a>在2012年1月7日, 发出最新的&#8221;全球www网站技术报告&#8221;.</p>
<p>    该统计基于对全球Alexa排名前100W的www网站做分析而得出.</p>
<p>    统计报告(<a href="http://w3techs.com/technologies/overview/programming_language/all" >Usage of server-side programming languages for websites</a>)显示, 相比2011年12月, 使用PHP构建的前100W名中的网站,又增长了约0.1%(30个), PHP占据的份额增长至77.3%, 依旧排名第一.<br/>
    <div id="attachment_2454"  class="wp-caption aligncenter"  style="width: 534px" ><a href="http://laruence-wordpress.stor.sinaapp.com/uploads/W3techs统计.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/W3techs统计.png"  alt=""  title="W3techs统计"  width="524"  height="244"  class="size-full wp-image-2454" /></a><p class="wp-caption-text" >W3Techs全球www技术统计报告2012年1月</p></div></p>
<p>    下图显示了1年来的各语言的趋势(来自:<a href="http://w3techs.com/technologies/history_overview/programming_language" >Historical trends in the usage of server-side programming languages for websites</a>):<br/>
 <div id="attachment_2456"  class="wp-caption aligncenter"  style="width: 310px" ><a href="http://laruence-wordpress.stor.sinaapp.com/uploads/www技术趋势1.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/www技术趋势1-300x71.png"  alt=""  title="www技术趋势"  width="300"  height="71"  class="size-medium wp-image-2456" /></a><p class="wp-caption-text" >历史发展趋势</p></div></p>
<p>    而, 下图是使用的PHP版本统计:<br/>
<div id="attachment_2457"  class="wp-caption aligncenter"  style="width: 449px" ><a href="http://laruence-wordpress.stor.sinaapp.com/uploads/PHP版本.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/PHP版本.png"  alt=""  title="PHP版本"  width="439"  height="146"  class="size-full wp-image-2457" /></a><p class="wp-caption-text" >PHP版本对比</p></div></p>
<p>    可见, 已经全面进入PHP5的时代了,但使用PHP4的网站还是有很大的数量.  </p>
<p>    上面提到的是www网站的服务端编程语言的对比, 而对于Client端的编程语言, 依旧还是Javascript的天下, 占到了90%以上:<br/>
     <div id="attachment_2463"  class="wp-caption aligncenter"  style="width: 399px" ><a href="http://laruence-wordpress.stor.sinaapp.com/uploads/未命名图片.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/未命名图片.png"  alt=""  title="Client端编程语言"  width="389"  height="147"  class="size-full wp-image-2463" /></a><p class="wp-caption-text" >Client端编程语言</p></div></p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/01/07</a>, <a href="http://www.xingdonghai.cn"  rel="external nofollow"  class="url" >伴夜</a> writes: 支持PHP</li><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/01/07</a>, <a href="http://www.cnxct.com"  rel="external nofollow"  class="url" >CFC4N</a> writes: 1,perl居然比python多，意料之外(我见识短)。
2,ASP.NET递减，JAVA缓慢增长。
3,ColdFusion居然出现了，而且，排第四，惊讶！(我见识短)。</li><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/01/08</a>, dryangkun writes: Hypertext Preprocessor从名字上就能看出PHP的定位，加油,PHP...</li><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/01/08</a>, <a href="http://www.hostsir.com"  rel="external nofollow"  class="url" >域名注册</a> writes: asp.net的上升趋势不能忽视，包含asp吗？</li><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/01/08</a>, <a href="http://www.tanglei.name"  rel="external nofollow"  class="url" >tanglei</a> writes: php用于快速迭代方面实在有优势。不过能否知道有多少在用php的面向对象编程呢?所在公司用php开发没有利用其OO方面的特性。</li><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/01/09</a>, nardoo writes: 用OO方面的特性的公司比较少吧， 受限于公司的历史代码，重构也比较麻烦。</li><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/01/09</a>, <a href="http://waibo.net/"  rel="external nofollow"  class="url" >Rhythm</a> writes: PHP和JS必须要双精！双精了以后，就不愁以后没前途了。</li><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/01/09</a>, <a href="http://blog.iterse.com"  rel="external nofollow"  class="url" >Iterse's blog</a> writes: 支持下！</li><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/01/15</a>, cers writes: 各种语言的设计初衷和目的不同，PHP就是为Web而生的，其它的语言则不是</li><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/01/17</a>, <a href="http://litefeel.com"  rel="external nofollow"  class="url" >lite3</a> writes: 虽然我是做AS的,但是对于网站,前端还是建议用HTML,JS, Flash要做游戏的</li><li><a href="http://www.laruence.com/2012/01/07/2453.html" >2012/02/03</a>, <a href="http://www.hihoku.com"  rel="external nofollow"  class="url" >蚂蚁</a> writes: 哈哈 python 居然有下降的趋势，ColdFusion 搞不懂为什么会排在这里</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/12/29/2412.html"  title="通过构造Hash冲突实现各种语言的拒绝服务攻击" >通过构造Hash冲突实现各种语言的拒绝服务攻击</a></li><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/02/2515.html"  title="我们什么时候应该使用异常?" >我们什么时候应该使用异常?</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li><li><a href="http://www.laruence.com/2012/01/11/2482.html"  title="PHP的历史" >PHP的历史</a></li><li><a href="http://www.laruence.com/2012/01/10/2469.html"  title="如何设置一个严格30分钟过期的Session" >如何设置一个严格30分钟过期的Session</a></li><li><a href="http://www.laruence.com/2011/12/30/2440.html"  title="PHP5.2.*防止Hash冲突拒绝服务攻击的Patch" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch</a></li><li><a href="http://www.laruence.com/2011/12/30/2435.html"  title="PHP数组的Hash冲突实例" >PHP数组的Hash冲突实例</a></li><li><a href="http://www.laruence.com/2011/12/06/2381.html"  title="更简单的重现PHP Core的调用栈" >更简单的重现PHP Core的调用栈</a></li><li><a href="http://www.laruence.com/2011/11/18/2305.html"  title="GBK编码PHP脚本导致语法错误(Zend Multibyte)" >GBK编码PHP脚本导致语法错误(Zend Multibyte)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2012/01/07/2453.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>PHP数组的Hash冲突实例</title>
		<link>http://www.laruence.com/2011/12/30/2435.html</link>
		<comments>http://www.laruence.com/2011/12/30/2435.html#comments</comments>
		<pubDate>Fri, 30 Dec 2011 06:30:46 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[转载]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[Hash collision]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[性能]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2435</guid>
		<description><![CDATA[   上一篇文章, 我介绍了一个<a href="http://www.laruence.com/2011/12/29/2412.html">利用Hash冲突(碰撞)来对各种语言(包括,PHP, Java, Ruby等等)实施拒绝服务攻击的可能</a>,  但是没有给出实例,  文章发出后, @Ferrari同学给出了一个另外一篇文章<a href="http://nikic.github.com/2011/12/28/Supercolliding-a-PHP-array.html">Supercolliding a PHP array</a>, 文章中作者介绍了一种基于PHP的冲突实例, 以及带来的性能恶化对比. 我就借花献佛, 翻译给大家看看.

    你知道不知道, 插入65536个经过构造的键值的元素到PHP数组, 会需要耗时30秒以上?  而一般的这个过程仅仅需要0.1秒..]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>本文地址: <a href="http://www.laruence.com/2011/12/30/2435.html"  title="Permanet Link to PHP数组的Hash冲突实例" >http://www.laruence.com/2011/12/30/2435.html</a></li>
<li>文章转自: <a href="http://nikic.github.com/2011/12/28/Supercolliding-a-PHP-array.html" >Supercolliding a PHP array</a></li>
</ul></div>
<p>
    上一篇文章, 我介绍了一个<a href="http://www.laruence.com/2011/12/29/2412.html" >利用Hash冲突(碰撞)来对各种语言(包括,PHP, Java, Ruby等等)实施拒绝服务攻击的可能</a>,  但是没有给出实例,  文章发出后, @Ferrari同学给出了一个另外一篇文章<a href="http://nikic.github.com/2011/12/28/Supercolliding-a-PHP-array.html" >Supercolliding a PHP array</a>, 文章中作者介绍了一种基于PHP的冲突实例, 以及带来的性能恶化对比. 我就借花献佛, 翻译给大家看看.</p>
<p>    你知道不知道, 插入65536个经过构造的键值的元素到PHP数组, 会需要耗时30秒以上?  而一般的这个过程仅仅需要0.1秒..</p>
<p>    请看如下的例子:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
$size = pow(2, 16); 

$startTime = microtime(true);
$array = array();
for ($key = 0, $maxKey = ($size - 1) * $size; $key &lt;= $maxKey; $key += $size) {
    $array[$key] = 0;
}
$endTime = microtime(true);
echo '插入 ', $size, ' 个恶意的元素需要 ', $endTime - $startTime, ' 秒', &quot;\n&quot;;

$startTime = microtime(true);
$array = array();
for ($key = 0, $maxKey = $size - 1; $key &lt;= $maxKey; ++$key) {
    $array[$key] = 0;
}
$endTime = microtime(true);
echo '插入 ', $size, ' 个普通元素需要 ', $endTime - $startTime, ' 秒', &quot;\n&quot;;
</pre>
<p>上面的例子, 在我的机器上的执行结果如下:</p>
<pre name="code"  class="sh_bash"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
插入 65536 个恶意的元素需要 43.1438360214 秒
插入 65536 个普通元素需要 0.0210378170013 秒
</pre>
<p>这个差别是不是很夸张?!</p>
<p>我在<a href="http://www.laruence.com/2011/12/29/2412.html" >上一篇文章中</a>介绍过,  经过特殊构造的键值,  使得PHP每一次插入都会造成Hash冲突, 从而使得PHP中array的底层Hash表退化成链表:<br/>
<div id="attachment_2415"  class="wp-caption aligncenter"  style="width: 618px" ><a href="http://laruence-wordpress.stor.sinaapp.com/uploads/Untitled3.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/Untitled3.png"  alt=""  title="Hash collision"  width="608"  height="223"  class="size-full wp-image-2415" /></a><p class="wp-caption-text" >Hash collision</p></div><br/>
这样在每次插入的时候PHP都需要遍历一遍这个链表, 大家可以想象,  第一次插入, 需要遍历0个元素, 第二次是1个, 第三次是3个, 第65536个是65535个, 那么总共就需要65534*65535/2=2147385345次遍历&#8230;.</p>
<p>那么, 这个键值是怎么构造的呢?</p>
<p>在PHP中,如果键值是数字, 那么Hash的时候就是数字本身,  一般的时候都是, index &#038; tableMask.  而tableMask是用来保证数字索引不会超出数组可容纳的元素个数值, 也就是数组个数-1.</p>
<p>PHP的Hashtable的大小都是2的指数, 比如如果你存入10个元素的数组, 那么数组实际大小是16, 如果存入20个, 则实际大小为32,   而63个话, 实际大小为64.  当你的存入的元素个数大于了数组目前的最多元素个数的时候, PHP会对这个数组进行扩容, 并且从新Hash.</p>
<p>现在,  我们假设要存入64个元素(中间可能会经过扩容, 但是我们只需要知道, 最后的数组大小是64, 并且对应的tableMask为63:0111111),  那么如果第一次我们存入的元素的键值为0,  则hash后的值为0,  第二次我们存入64, hash(1000000 &#038; 0111111)的值也为0, 第三次我们用128, 第四次用192&#8230; 就可以使得底层的PHP数组把所有的元素都Hash到0号bucket上, 从而使得Hash表退化成链表了.</p>
<p>当然, 如果键值是字符串的话, 就稍微比较麻烦一些了, 但是PHP的<a href="http://www.laruence.com/2009/07/23/994.html" >Hash算法</a>是开源的, 已知的, 所以有心人也可以做到&#8230;<br/>
<script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_bash.js" ></script></p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2011/12/30</a>, <a href="http://kimbs.cn"  rel="external nofollow"  class="url" >kim</a> writes: 沙发！
简单地说就是，通过构造一个 url ，或者一个 form ，参数的 key 就按这么 $key += $size 计算，那么就能拖慢所有使用存在此缺陷的 server ~，oh my god.</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2011/12/30</a>, mahone writes: 灰常不错，受教了。。。</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2011/12/30</a>, mahone writes: 刚测试了下，发现个问题，请教下
在我本地虚拟机（32位ubuntu系统，512m内存，1核cpu，2.66GHz）上跑上面的程序：
插入 65536 个恶意的元素需要 90.800883054733 秒
插入 65536 个普通元素需要 0.026834011077881 秒
服务器（64位系统，2g内存，4核1.60GHz）上跑：
插入 65536 个恶意的元素需要 190.03647112846 秒
插入 65536 个普通元素需要 0.027021884918213 秒

这个差距是因为cpu频率的关系？php能利用多核的优势么？还是因为系统是32位或者64位的关系？</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2011/12/30</a>, <a href="http://www.laruence.com/2011/12/30/2440.html"  rel="external nofollow"  class="url" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch | 风雪之隅</a> writes: [...] PHP数组的Hash冲突实例  ), 这个攻击方法危害很高, 攻击成本也很小. [...]</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2011/12/30</a>, <a href="http://hjin.me"  rel="external nofollow"  class="url" >HJin_me</a> writes: 鸟哥，你的半官方补丁能发布出来么～～对很多人来说，非稳定版本的不敢用啊。</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2011/12/30</a>, <a href="http://blog.biaojita.com"  rel="external nofollow"  class="url" >dk</a> writes: 控制一下GPC三个超全局变量的解析时间是否就解决了潜在的DDOS攻击呢？</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2011/12/30</a>, <a href="http://www.xingdonghai.cn/a-new-supercolliding-with-array-of-php/"  rel="external nofollow"  class="url" >关于最近PHP的Array爆出的冲突问题 | 东海博客</a> writes: [...] 详细内容：http://www.laruence.com/2011/12/30/2435.html [...]</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2011/12/31</a>, <a href="http://blog.csdn.net/linvo"  rel="external nofollow"  class="url" >linvo</a> writes: 请教鸟哥，有一点我还是不太明白，$size=pow(2, n)中n取值的缘由？
我把代码做了一些修改后测试发现，当n取值为14~18的时候，效果最好。大于或小于的话，速度都会明显变快。</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2011/12/31</a>, wow writes: [root@WangXJ php_test]# time  php f.php 
插入 65536 个普通元素需要  0.053505897521973 sec

real	0m0.086s
user	0m0.080s
sys	0m0.004s

大神 我想请教下 为什么time 命令统计的时间real time会大于php自己统计的时间呢</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2012/01/06</a>, a writes: 请问，怎么用这个BUG攻击你的blog？挺起来好象这BUG很厉害的样子。</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2012/01/07</a>, <a href="http://blog.jobbole.com/11516/"  rel="external nofollow"  class="url" >PHP哈希表碰撞攻击原理 - 博客 - 伯乐在线</a> writes: [...] [4] PHP数组的Hash冲突实例 [...]</li><li><a href="http://www.laruence.com/2011/12/30/2435.html" >2012/01/11</a>, <a href="http://ok"  rel="external nofollow"  class="url" >jimmyyem</a> writes: 看了好久，为了一些人才看明白，很受教</li></ul><hr/><h2>Related posts:</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2009/07/23/994.html"  rel="bookmark"  title="Permanent Link: PHP中的Hash算法" >PHP中的Hash算法</a></li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2009/10/15/1131.html"  title="提升PHP性能之改变Zend引擎分发方式" >提升PHP性能之改变Zend引擎分发方式</a></li><li><a href="http://www.laruence.com/2009/07/23/994.html"  title="PHP中的Hash算法" >PHP中的Hash算法</a></li><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/02/2515.html"  title="我们什么时候应该使用异常?" >我们什么时候应该使用异常?</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li><li><a href="http://www.laruence.com/2012/01/11/2482.html"  title="PHP的历史" >PHP的历史</a></li><li><a href="http://www.laruence.com/2012/01/10/2469.html"  title="如何设置一个严格30分钟过期的Session" >如何设置一个严格30分钟过期的Session</a></li><li><a href="http://www.laruence.com/2012/01/07/2453.html"  title="2012年1月全球www网站技术报告" >2012年1月全球www网站技术报告</a></li><li><a href="http://www.laruence.com/2011/12/30/2440.html"  title="PHP5.2.*防止Hash冲突拒绝服务攻击的Patch" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch</a></li><li><a href="http://www.laruence.com/2011/12/29/2412.html"  title="通过构造Hash冲突实现各种语言的拒绝服务攻击" >通过构造Hash冲突实现各种语言的拒绝服务攻击</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/12/30/2435.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Yaf的性能对比测试</title>
		<link>http://www.laruence.com/2011/11/05/2262.html</link>
		<comments>http://www.laruence.com/2011/11/05/2262.html#comments</comments>
		<pubDate>Sat, 05 Nov 2011 02:10:49 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[转载]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[Ci]]></category>
		<category><![CDATA[Yaf]]></category>
		<category><![CDATA[Yii]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[性能测试]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2262</guid>
		<description><![CDATA[ 从Yaf诞生以来, 我就没把它与其他框架的性能对比测试放出来,  原因呢, 也很简单, 我懒,  没对比过(只是和原生的PHP做了简单的对比).

   最近, 关注Yaf的人越来越多,  今天从访问来源发现了这个页面<a href="http://www.reddit.com/r/PHP/comments/m0akq/the_yet_another_framework_yaf_php_extension_for/">reddit.com</a>,  继而发现了<a href="http://www.ruilog.com/">Eryx</a>朋友,  做的一份<a href="https://github.com/eryx/labs/tree/master/php-framework-benchmark/result-20110701">性能对比测试</a>,  我就借花谢佛,  转载了过来.

   测试机器:
<coolcode lang="bash" linenum="off">
* Hardware

    CPU: Intel Core i5 750 (2.67GHz x4)
    RAM: 4GB

* Software
Debian 6.0.2 x86_64 (2.6.32-5-amd64)

apache 2.2.16
    mpm-prefork
    mod-php5

php 5.3.6
    php-apc 3.1.3p1
</coolcode>]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>本文地址: <a href="http://www.laruence.com/2011/11/05/2262.html"  title="Permanet Link to Yaf的性能对比测试" >http://www.laruence.com/2011/11/05/2262.html</a></li>
<li>文章转自: <a href="https://github.com/eryx/labs/blob/master/php-framework-benchmark/result-20110701" >https://github.com/eryx/labs/blob/master/php-framework-benchmark/result-20110701</a></li>
</ul></div>
<p>
   从Yaf诞生以来, 我就没把它与其他框架的性能对比测试放出来,  原因呢, 也很简单, 我懒,  没对比过(只是和原生的PHP做了简单的对比).</p>
<p>   最近, 关注Yaf的人越来越多,  今天从访问来源发现了这个页面<a href="http://www.reddit.com/r/PHP/comments/m0akq/the_yet_another_framework_yaf_php_extension_for/" >reddit.com</a>,  继而发现了<a href="http://www.ruilog.com/" >Eryx</a>朋友,  做的一份<a href="https://github.com/eryx/labs/tree/master/php-framework-benchmark/result-20110701" >性能对比测试</a>,  我就借花谢佛,  转载了过来.</p>
<p>  <b>后记(2011-12-02补充), Yaf 2.1做了一些性能优化的升级, 基于Yaf 2.1的性能测试报告可以参见: <a href="http://www.laruence.com/2011/12/02/2333.html" >Yaf 2.1性能测试</a></b></p>
<p>  <b>Postscript(added at 2011-12-02), Yaf 2.1 did a lot of work to improve performance and reduce memory usage, a new bechmark could be found at  <a href="http://www.laruence.com/2011/12/02/2333.html" >Yaf 2.1 Benchmark</a></b></p>
<p>   测试机器:</p>
<pre name="code"  class="sh_bash"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
* Hardware

    CPU: Intel Core i5 750 (2.67GHz x4)
    RAM: 4GB

* Software
Debian 6.0.2 x86_64 (2.6.32-5-amd64)

apache 2.2.16
    mpm-prefork
    mod-php5

php 5.3.6
    php-apc 3.1.3p1
</pre>
<p>   <a href="http://laruence-wordpress.stor.sinaapp.com/uploads/ab1.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/ab1.png"  alt=""  title="ab1"  width="680"  height="500"  class="aligncenter size-full wp-image-2270" /></a>  <a href="http://laruence-wordpress.stor.sinaapp.com/uploads/ab2.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/ab2.png"  alt=""  title="ab2"  width="680"  height="500"  class="aligncenter size-full wp-image-2271" /></a>  <a href="http://laruence-wordpress.stor.sinaapp.com/uploads/funs.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/funs.png"  alt=""  title="funs"  width="680"  height="500"  class="aligncenter size-full wp-image-2263" /></a>  <a href="http://laruence-wordpress.stor.sinaapp.com/uploads/memuse.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/memuse.png"  alt=""  title="memuse"  width="680"  height="500"  class="aligncenter size-full wp-image-2269" /></a>  <a href="http://laruence-wordpress.stor.sinaapp.com/uploads/time.png" ><img src="http://laruence-wordpress.stor.sinaapp.com/uploads/time.png"  alt=""  title="time"  width="680"  height="500"  class="aligncenter size-full wp-image-2272" /></a></p>
<p>  看时间戳, 这个应该是在Yaf 2.1之前做的测试,  而Yaf2.1还做了一些性能优化, 数据应该还会更好看那么一点,  <img src="http://www.laruence.com/wp-includes/images/smilies/icon_smile.gif"  alt=":)"  class="wp-smiley" /> </p>
<p>  后记(2011-11-25补充): </p>
<blockquote><p>
Eryx | 21 Nov 2011 16:24 edit<br/>
很惊喜，这竟然是我的测试 </p>
<p>上面有提到测试用例，可以参考测试汇总:</p>
<p>http://www.ruilog.com/blog/view/5271.html</p>
<p>刚刚下载了最新的 yaf 2.1.3，相比 2.0.x 版本, 在 “ab -c 100 -n 30000″ 下的并发已经从 5331 提高到 6800 左右！ （软硬件环境仍然相同）
</p></blockquote>
<p><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_bash.js" ></script></p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/05</a>, <a href="http://66beta.com"  rel="external nofollow"  class="url" >66</a> writes: 最近在学Yii，原来Yii跟CI还是差一点的，ZF太恐怖了，但是感觉ZF的组织架构是最简单的，就是太臃肿了</li><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/05</a>, 大草原 writes: 抽点时间来整yaf社区支持吧！</li><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/06</a>, <a href="http://www.magentochina.org"  rel="external nofollow"  class="url" >Magento中文</a> writes: zend framework太让人吃惊了...我一直用他.有空再看看你的yaf</li><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/06</a>, <a href="http://www.magentochina.org"  rel="external nofollow"  class="url" >Magento中文</a> writes: 其实这个报告还不完整..
 应该给出每个框架跑的代码..
而且只是在apache下面跑了..我想知道各种框架在zend server(虽然还是apache)和nginx下的速度..</li><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/06</a>, <a href="http://blog.cosnis.com"  rel="external nofollow"  class="url" >cosnis</a> writes: 不支持php3.8  淡定的飘过</li><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/07</a>, <a href="http://liruqi.tumblr.com"  rel="external nofollow"  class="url" >liruqi</a> writes: MicroMVC 的数据也挺不错啊~</li><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/09</a>, helloyou writes: 你得把手册翻译个英文版了...省得老外兄弟们用google翻译</li><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/09</a>, <a href="http://www.initphp.com"  rel="external nofollow"  class="url" >zhuli</a> writes: 每天来拜一拜，PHP写得顺畅点，哈哈哈</li><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/21</a>, <a href="http://www.ruilog.com"  rel="external nofollow"  class="url" >Eryx</a> writes: 很惊喜，这竟然是我的测试 :)

上面有提到测试用例，可以参考测试汇总:
http://www.ruilog.com/blog/view/5271.html

刚刚下载了最新的 yaf 2.1.3，相比 2.0.x 版本, 在 "ab -c 100 -n 30000" 下的并发已经从 5331 提高到 6800 左右！ （软硬件环境仍然相同）</li><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/24</a>, skyblue writes: MicroMVC的rps比yaf都高?
这是什么道理?</li><li><a href="http://www.laruence.com/2011/11/05/2262.html" >2011/11/25</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @Eryx 你能再重新弄个2.1的测试对比图么?  嘿嘿, 多谢多谢</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/12/02/2333.html"  title="Yaf 2.1性能测试(Yaf 2.1 Benchmark)" >Yaf 2.1性能测试(Yaf 2.1 Benchmark)</a></li><li><a href="http://www.laruence.com/2011/06/28/2088.html"  title="在Windows下编译Yaf" >在Windows下编译Yaf</a></li><li><a href="http://www.laruence.com/2011/06/26/2083.html"  title="Yaf已提交到PECL" >Yaf已提交到PECL</a></li><li><a href="http://www.laruence.com/2011/05/31/2025.html"  title="在中国PHP技术高峰论坛(2011)上演讲的PPT" >在中国PHP技术高峰论坛(2011)上演讲的PPT</a></li><li><a href="http://www.laruence.com/2011/05/12/2009.html"  title="Yaf-A PHP Framework Extension" >Yaf-A PHP Framework Extension</a></li><li><a href="http://www.laruence.com/2010/10/12/1763.html"  title="PHP的命名空间的实现" >PHP的命名空间的实现</a></li><li><a href="http://www.laruence.com/2010/09/04/1736.html"  title="Yaf-一个PHP扩展实现的PHP框架" >Yaf-一个PHP扩展实现的PHP框架</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/11/05/2262.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>上传进度支持(Upload progress in sessions)</title>
		<link>http://www.laruence.com/2011/10/10/2217.html</link>
		<comments>http://www.laruence.com/2011/10/10/2217.html#comments</comments>
		<pubDate>Mon, 10 Oct 2011 05:40:56 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[PHP5.4新特性]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[Upload progress]]></category>
		<category><![CDATA[上传进度]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2217</guid>
		<description><![CDATA[文件上传进度反馈, 这个需求在当前是越来越普遍,  比如大附件邮件.  在PHP5.4以前,  我们可以通过<a href="http://www.php.net/manual/zh/apc.configuration.php#ini.apc.rfc1867"  target="_blank">APC</a>提供的功能来实现.  或者使用PECL扩展<a href="http://pecl.php.net/package/uploadprogress" target="_blank">uploadprogress</a>来实现.

   虽然说, 它们能很好的解决现在的问题,  但是也有很明显的不足: 
<ul>
<li>1. 他们都需要额外安装(我们并没有打算把APC加入PHP5.4)</li>
<li>2. 它们都使用本地机制来存储这些信息, APC使用共享内存, 而uploadprogress使用文件系统(不考虑NFS), 这在多台前端机的时候会造成麻烦.</li>
</ul>

   从PHP的角度来说,  最好的储存这些信息的地方应该是SESSION, 首先它是PHP原生支持的机制. 其次, 它可以被配置到存放到任何地方(支持多机共享).  

   正因为此,  Arnaud Le Blanc提出了针对Session报告上传进度的<a href="http://wiki.php.net/rfc/session_upload_progress">RFC</a>, 并且现在实现也已经包含在了PHP5.4的主干中.]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/10/10/2217.html"  title="Permanet Link to 上传进度支持(Upload progress in sessions)" >http://www.laruence.com/2011/10/10/2217.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
   文件上传进度反馈, 这个需求在当前是越来越普遍,  比如大附件邮件.  在PHP5.4以前,  我们可以通过<a href="http://www.php.net/manual/zh/apc.configuration.php#ini.apc.rfc1867"  target="_blank" >APC</a>提供的功能来实现.  或者使用PECL扩展<a href="http://pecl.php.net/package/uploadprogress"  target="_blank" >uploadprogress</a>来实现.</p>
<p>   虽然说, 它们能很好的解决现在的问题,  但是也有很明显的不足: </p>
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>1. 他们都需要额外安装(我们并没有打算把APC加入PHP5.4)</li>
<li>2. 它们都使用本地机制来存储这些信息, APC使用共享内存, 而uploadprogress使用文件系统(不考虑NFS), 这在多台前端机的时候会造成麻烦.</li>
</ul>
<p>   从PHP的角度来说,  最好的储存这些信息的地方应该是SESSION, 首先它是PHP原生支持的机制. 其次, 它可以被配置到存放到任何地方(支持多机共享).  </p>
<p>   正因为此,  Arnaud Le Blanc提出了针对Session报告上传进度的<a href="http://wiki.php.net/rfc/session_upload_progress" >RFC</a>, 并且现在实现也已经包含在了PHP5.4的主干中.</p>
<p>   这个新特性, 提供了一些新的INI配置, 他们和APC的相关配置很类似:</p>
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>session.upload_progress.enabled[=1] : 是否启用上传进度报告(默认开启)</li>
<li>session.upload_progress.cleanup[=1] : 是否在上传完成后及时删除进度数据(默认开启, 推荐开启).</li>
<li>session.upload_progress.prefix[=upload_progress_] : 进度数据将存储在_SESSION[session.upload_progress.prefix . _POST[session.upload_progress.name]]</li>
<li>session.upload_progress.name[=PHP_SESSION_UPLOAD_PROGRESS] : 如果_POST[session.upload_progress.name]没有被设置, 则不会报告进度.</li>
<li>session.upload_progress.freq[=1%] : 更新进度的频率(已经处理的字节数), 也支持百分比表示&#8217;%&#8217;.</li>
<li>session.upload_progress.min_freq[=1.0] : 更新进度的时间间隔(秒级)</li>
</ul>
<p>  对于如下的上传表单:</p>
<pre name="code"  class="sh_html"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;form action=&quot;upload.php&quot; method=&quot;POST&quot; enctype=&quot;multipart/form-data&quot;&gt;
 &lt;input type=&quot;hidden&quot;
     name=&quot;&lt;?php echo ini_get(&quot;session.upload_progress.name&quot;); ?&gt;&quot; value=&quot;laruence&quot; /&gt;
 &lt;input type=&quot;file&quot; name=&quot;file1&quot; /&gt;
 &lt;input type=&quot;file&quot; name=&quot;file2&quot; /&gt;
 &lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
</pre>
<p>  如果我们上传一个足够大的文件(网速要是足够慢就更好:P),  我们就可以从_SESSION中, 得到类似下面的进度信息:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
$_SESSION[&quot;upload_progress_laruence&quot;] = array(
 &quot;start_time&quot; =&gt; 1234567890,   // 请求时间
 &quot;content_length&quot; =&gt; 57343257, // 上传文件总大小
 &quot;bytes_processed&quot; =&gt; 453489,  // 已经处理的大小
 &quot;done&quot; =&gt; false,              // 当所有上传处理完成后为TRUE
 &quot;files&quot; =&gt; array(
  0 =&gt; array(
   &quot;field_name&quot; =&gt; &quot;file1&quot;,       // 表单中上传框的名字
   // The following 3 elements equals those in $_FILES
   &quot;name&quot; =&gt; &quot;foo.avi&quot;,
   &quot;tmp_name&quot; =&gt; &quot;/tmp/phpxxxxxx&quot;,
   &quot;error&quot; =&gt; 0,
   &quot;done&quot; =&gt; true,                // 当这个文件处理完成后会变成TRUE
   &quot;start_time&quot; =&gt; 1234567890,    // 这个文件开始处理时间
   &quot;bytes_processed&quot; =&gt; 57343250, // 这个文件已经处理的大小
  ),
  // An other file, not finished uploading, in the same request
  1 =&gt; array(
   &quot;field_name&quot; =&gt; &quot;file2&quot;,
   &quot;name&quot; =&gt; &quot;bar.avi&quot;,
   &quot;tmp_name&quot; =&gt; NULL,
   &quot;error&quot; =&gt; 0,
   &quot;done&quot; =&gt; false,
   &quot;start_time&quot; =&gt; 1234567899,
   &quot;bytes_processed&quot; =&gt; 54554,
  ),
 )
);
</pre>
<p>   这个是不是很方便呢?  </p>
<p>   但是还是要提醒一下, PHP 5.4还处于开发阶段, 在最终release之前, 任何新特性都可能被调整或者更改. 如果大家有任何建议, 也欢迎反馈, 帮助我们使得PHP变得更好.</p>
<p>   谢谢</p>
<p>   Johannes的blog也介绍过: <a href="http://schlueters.de/blog/archives/151-Upload-Progress-in-PHP-trunk.html"  target="_blank" >http://schlueters.de/blog/archives/151-Upload-Progress-in-PHP-trunk.html</a></p>
<p>   更多更新信息, 请关注: <a href="http://svn.php.net/viewvc/php/php-src/branches/PHP_5_4/NEWS?view=markup"  target="_blank" >Changelog</a><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_html.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script></p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/10/10/2217.html" >2011/10/10</a>, wclssdn writes: 这个就太帅了~~~ 哈哈哈</li><li><a href="http://www.laruence.com/2011/10/10/2217.html" >2011/10/10</a>, pAUL gAO writes: 也可以用 NGINX 的扩展支持，好处是上传时不会消耗 PHP 进程。</li><li><a href="http://www.laruence.com/2011/10/10/2217.html" >2011/10/10</a>, jackywdx writes: cool</li><li><a href="http://www.laruence.com/2011/10/10/2217.html" >2011/11/03</a>, <a href="http://hi.baidu.com/u2solu"  rel="external nofollow"  class="url" >solu</a> writes: 这功能太实用了！</li><li><a href="http://www.laruence.com/2011/10/10/2217.html" >2011/11/06</a>, <a href="http://ihacklog.com"  rel="external nofollow"  class="url" >荒野无灯</a> writes: 有原生支持就比较好了。</li><li><a href="http://www.laruence.com/2011/10/10/2217.html" >2011/12/21</a>, <a href="http://geekdream.com"  rel="external nofollow"  class="url" >leo</a> writes: 这个好！！</li><li><a href="http://www.laruence.com/2011/10/10/2217.html" >2012/01/16</a>, <a href="http://3haku.net"  rel="external nofollow"  class="url" >princehaku</a> writes: 方便</li></ul><hr/><h2>Related posts:</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2012/01/11/2482.html"  rel="bookmark"  title="Permanent Link: PHP的历史" >PHP的历史</a></li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2009/12/05/1172.html"  title="PHP5.2.x + APC的一个bug的定位" >PHP5.2.x + APC的一个bug的定位</a></li><li><a href="http://www.laruence.com/2012/01/10/2469.html"  title="如何设置一个严格30分钟过期的Session" >如何设置一个严格30分钟过期的Session</a></li><li><a href="http://www.laruence.com/2011/12/19/2409.html"  title="之前提到的PHP5.4一个注意点的update" >之前提到的PHP5.4一个注意点的update</a></li><li><a href="http://www.laruence.com/2011/12/06/2381.html"  title="更简单的重现PHP Core的调用栈" >更简单的重现PHP Core的调用栈</a></li><li><a href="http://www.laruence.com/2011/11/28/2317.html"  title="PHP5.4中一个需要注意的变化(Chained string offsets)" >PHP5.4中一个需要注意的变化(Chained string offsets)</a></li><li><a href="http://www.laruence.com/2011/11/11/2296.html"  title="PHP5.4新特性-解引用实例化" >PHP5.4新特性-解引用实例化</a></li><li><a href="http://www.laruence.com/2011/11/04/2258.html"  title="三元式(ternary)性能优化" >三元式(ternary)性能优化</a></li><li><a href="http://www.laruence.com/2011/10/19/2247.html"  title="Zend Signal in PHP 5.4" >Zend Signal in PHP 5.4</a></li><li><a href="http://www.laruence.com/2011/10/10/2232.html"  title="二进制直接量(binary number format)" >二进制直接量(binary number format)</a></li><li><a href="http://www.laruence.com/2011/10/10/2229.html"  title="函数类型提示(Callable typehint)" >函数类型提示(Callable typehint)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/10/10/2217.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Array dereferencing</title>
		<link>http://www.laruence.com/2011/10/10/2212.html</link>
		<comments>http://www.laruence.com/2011/10/10/2212.html#comments</comments>
		<pubDate>Mon, 10 Oct 2011 04:57:44 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[Array dereferencing]]></category>
		<category><![CDATA[PHP5.4新特性]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2212</guid>
		<description><![CDATA[ 首先, 这个标题我不太清楚怎么翻译才能表达确切的意思, 直译不太妥当.

    在PHP5.4中, 有一个新的改进:
<coolcode lang="bash" linenum="off">
- Added array dereferencing support. (Felipe)
</coolcode>
]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/10/10/2212.html"  title="Permanet Link to Array dereferencing" >http://www.laruence.com/2011/10/10/2212.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
    首先, 这个标题我不太清楚怎么翻译才能表达确切的意思, 直译不太妥当.</p>
<p>    在PHP5.4中, 有一个新的改进:</p>
<pre name="code"  class="sh_bash"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
- Added array dereferencing support. (Felipe)
</pre>
<p>    在以前, 我们如果定义一个返回数组的函数:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
function foo() {
    return array(1, 2, 3);
}
</pre>
<p>   那么, 如果我要获取返回数组中的第二个元素, 就只能:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
list(, $mid, ) = foo();
</pre>
<p>或者:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
$tmp  =  $foo();
$mid = $tmp[1];
</pre>
<p>   而从5.4开始, 我们就不需要这么麻烦了, 只需要:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
$mid = foo()[1];
</pre>
<p>   另外, 也可以使用引用:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
function &amp;getTable() {
     return $GLOBALS;
}

getTable()[&quot;foo&quot;] = &quot;laruence&quot;;

echo $foo;

//laruence
</pre>
<p>  很方便吧?  呵呵.  最后提醒一下, PHP 5.4还处于开发阶段, 在最终release之前, 任何新特性都可能被调整或者更改. 如果大家有任何建议, 也欢迎反馈, 帮助我们使得PHP变得更好.</p>
<p>  谢谢<script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_bash.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script></p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/10/10/2212.html" >2011/10/10</a>, Demon writes: 加Q交个朋友~PHPer.</li><li><a href="http://www.laruence.com/2011/10/10/2212.html" >2011/10/10</a>, Demon writes: 忘写Q了 = =  [防止spam已保护性隐藏]
Sina weibo http://weibo.com/lonedemon</li><li><a href="http://www.laruence.com/2011/10/10/2212.html" >2011/10/10</a>, <a href="http://www.feiyan.info"  rel="external nofollow"  class="url" >飞晏</a> writes: 这样确实可以省一个变量的功夫。
只取一个元素这样用最方便，取多个元素（不一定是全部）就不能这样了吧。</li><li><a href="http://www.laruence.com/2011/10/10/2212.html" >2011/10/10</a>, wynn writes: 个人认为在这个语境下，“dereferencing”可以翻译成“成员访问解析”。这个更新的内容可以翻译成“增加了数组成员访问解析支持”。（实际上完整的说在最前面应该加上“对函数返回结果”的定语）
翻PHP的过往的一些信息，可以看出“dereferencing”这个字眼大致上是指“对（尝试）访问对象的属性（的语法）的解析”，也就是指诸如“-&gt;property” 这样的语法。
在5.3上，可以运行下面几个代码：
//代码1：对变量
$obj = new stdClass();
$obj-&gt;a = 'string_a';
echo $obj-&gt;a;

//代码2：对数组元素
$array['a'] = new StdClass();
$array['a']-&gt;a = 'string_a';
echo $array['a']-&gt;a;

//代码3：对函数返回结果
function test(){
	$obj = new stdClass();
	$obj-&gt;a = 'string_a';
	return $obj;
}
echo test()-&gt;a;

在所有这3种情况下，“-&gt;”操作都会尝试把之前的结果作为目标object，解析属性访问。而对于数组，只有前两种情况是允许的：
//代码1：对变量
$arr = array();
$arr['a'] = 'string_a';
echo $arr['a'];

//代码2：对数组元素
$array['a'] = array();
$array['a']['a'] = 'string_a';
echo $array['a']['a'];

//代码3：对函数返回结果，出错。
function test(){
	$array = array();
	$array['a'] = 'string_a';
	return $array;
}
echo test()['a'];

实际上如果不考虑对象的方法，只关注数据的话，对象和数组都可以当作hash表来看，二者之间很相似，那么对函数返回结果不能直接执行数组成员访问，就有点歧视的感觉……
这个新特性实际上就是把这个缺陷补上。
对象内的数据叫“属性”，数组内的数据叫“元素”，个人认为可以统一用“成员”来称呼，来体现这种关联性。</li><li><a href="http://www.laruence.com/2011/10/10/2212.html" >2011/10/11</a>, <a href="https://twitter.com/snakevil"  rel="external nofollow"  class="url" >Snakevil</a> writes: 我觉得“dereferencing”翻译成“反向引用”不错。“de-”前缀词根也可以做“反向”来理解。</li><li><a href="http://www.laruence.com/2011/10/10/2212.html" >2011/10/25</a>, <a href="http://diyism.com"  rel="external nofollow"  class="url" >diyism</a> writes: dereference的意思:c语言里的*就是个"解除引用运算符", *aPointer就是对aPointer解除引用以获得实体</li><li><a href="http://www.laruence.com/2011/10/10/2212.html" >2011/10/27</a>, Wilson writes: 一直期待着php能像js那样用数组呢，没想到现在支持了，真开心啊，return_array()[1]</li><li><a href="http://www.laruence.com/2011/10/10/2212.html" >2011/11/01</a>, GAN writes: 这个确实方便许多啊</li><li><a href="http://www.laruence.com/2011/10/10/2212.html" >2011/11/19</a>, Tim writes: 在Perl中,这个叫数组切片.</li></ul><hr/><h2>Related posts:</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/07/02/2097.html"  rel="bookmark"  title="Permanent Link: PHP5.4的新特性" >PHP5.4的新特性</a></li><li><a href="http://www.laruence.com/2010/05/28/1565.html"  rel="bookmark"  title="Permanent Link: PHP错误抑制符(@)导致引用传参失败的Bug" >PHP错误抑制符(@)导致引用传参失败的Bug</a></li><li><a href="http://www.laruence.com/2011/06/19/2047.html"  rel="bookmark"  title="Permanent Link: PLua &#8211; Lua for PHP" >PLua &#8211; Lua for PHP</a></li><li><a href="http://www.laruence.com/2008/06/18/221.html"  rel="bookmark"  title="Permanent Link: 深入理解PHP原理之Opcodes" >深入理解PHP原理之Opcodes</a></li><li><a href="http://www.laruence.com/2011/07/13/2110.html"  rel="bookmark"  title="Permanent Link: PHP RFC: 让PHP的foreach支持list" >PHP RFC: 让PHP的foreach支持list</a></li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/12/19/2409.html"  title="之前提到的PHP5.4一个注意点的update" >之前提到的PHP5.4一个注意点的update</a></li><li><a href="http://www.laruence.com/2011/12/06/2381.html"  title="更简单的重现PHP Core的调用栈" >更简单的重现PHP Core的调用栈</a></li><li><a href="http://www.laruence.com/2011/11/28/2317.html"  title="PHP5.4中一个需要注意的变化(Chained string offsets)" >PHP5.4中一个需要注意的变化(Chained string offsets)</a></li><li><a href="http://www.laruence.com/2011/11/11/2296.html"  title="PHP5.4新特性-解引用实例化" >PHP5.4新特性-解引用实例化</a></li><li><a href="http://www.laruence.com/2011/11/04/2258.html"  title="三元式(ternary)性能优化" >三元式(ternary)性能优化</a></li><li><a href="http://www.laruence.com/2011/10/19/2247.html"  title="Zend Signal in PHP 5.4" >Zend Signal in PHP 5.4</a></li><li><a href="http://www.laruence.com/2011/10/10/2232.html"  title="二进制直接量(binary number format)" >二进制直接量(binary number format)</a></li><li><a href="http://www.laruence.com/2011/10/10/2229.html"  title="函数类型提示(Callable typehint)" >函数类型提示(Callable typehint)</a></li><li><a href="http://www.laruence.com/2011/10/10/2217.html"  title="上传进度支持(Upload progress in sessions)" >上传进度支持(Upload progress in sessions)</a></li><li><a href="http://www.laruence.com/2011/10/10/2204.html"  title="JsonSerializable接口" >JsonSerializable接口</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/10/10/2212.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>mysqlnd插件mysqlnd_ms的介绍</title>
		<link>http://www.laruence.com/2011/10/05/2192.html</link>
		<comments>http://www.laruence.com/2011/10/05/2192.html#comments</comments>
		<pubDate>Wed, 05 Oct 2011 12:06:37 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[MySQL/PostgreSQL]]></category>
		<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[fail over]]></category>
		<category><![CDATA[load balancing]]></category>
		<category><![CDATA[mysqlnd]]></category>
		<category><![CDATA[mysqlnd_ms]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[read-write splitting]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2192</guid>
		<description><![CDATA[ 从PHP5.3开始, MySQL team专为PHP开发的MySQL连接库mysqlnd(MySQL native driver for PHP)终于和PHP一起发布了. mysqlnd的主要目的是为了解决长久以来mysql和php的license的问题.  它将作为PHP的源代码的一部分和PHP一起发布.

    今天, 我要为大家介绍一个mysqlnd的插件:mysqlnd_ms,  这个插件是由mysqlnd的开发者Andrey Hristov,<a href="http://blog.ulf-wendel.de/">Ulf Wendel</a>和<a href="http://schlueters.de/blog/">johannes</a>一起开发的, 目前发布在PECL: <a href="http://pecl.php.net/package/mysqlnd_ms">mysqlnd_ms</a>]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/10/05/2192.html"  title="Permanet Link to mysqlnd插件mysqlnd_ms的介绍" >http://www.laruence.com/2011/10/05/2192.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
    从PHP5.3开始, MySQL team专为PHP开发的MySQL连接库mysqlnd(MySQL native driver for PHP)终于和PHP一起发布了. mysqlnd的主要目的是为了解决长久以来mysql和php的license的问题.  它将作为PHP的源代码的一部分和PHP一起发布.</p>
<p>    今天, 我要为大家介绍一个mysqlnd的插件:mysqlnd_ms,  这个插件是由mysqlnd的开发者Andrey Hristov,<a href="http://blog.ulf-wendel.de/" >Ulf Wendel</a>和<a href="http://schlueters.de/blog/" >johannes</a>一起开发的, 目前发布在PECL: <a href="http://pecl.php.net/package/mysqlnd_ms" >mysqlnd_ms</a></p>
<p>    在这个扩展的介绍页面我们可以看到它的功能描述:</p>
<blockquote><p>
The replication and load balancing plugin is a plugin for the mysqlnd library. It can be used with PHP MySQL extensions (ext/mysql, ext/mysqli, PDO_MySQL). if they are compiled to use mysqlnd. The plugin inspects queries to do read-write splitting. Read-only queries are send to configured MySQL replication slave servers all other queries are redirected to the MySQL replication master server. Very little, if any, application changes required, dependent on the usage scenario required.
</p></blockquote>
<p>    这个扩展, 主要实现了, 连接保持和切换, 负载均衡和读写分离等, 也就是说, 这个扩展会去分别PHP发给MySQL的query,  如果是&#8221;读&#8221;的query, 就会把query发送给从库(配置中指明), 并且支持负载均衡;  而如果是&#8221;写&#8221;的query,  就会把query发送给主库.</p>
<p>    不过这个扩展需要搭配mysqlnd一起使用(从PHP5.4 beta1开始, 我们已经把mysqlnd作为mysql, mysqli, pdo的默认链接目标, 当然, 你也可以通过&#8211;with-mysql=***来制定你想要链接到libmysql).</p>
<p>    这个扩展使用的方法也很简单, 首先在<b>php.ini</b>中定义配置:</p>
<pre name="code"  class="sh_ini"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
mysqlnd_ms.enable=1
mysqlnd_ms.ini_file=/path/to/mysqlnd_ms_plugin.ini
</pre>
<p>    之后, 在你指明的mysqlnd_ms_plugin.ini中配置好MySQL的主从库就好了:</p>
<pre name="code"  class="sh_ini"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
[myapp]
master[]=localhost:/tmp/mysql.sock
slave[]=192.168.2.27:3306
</pre>
<p>   <b>博文发出以后, Ulf提醒我, 从1.1.0开始, 配置文件改为JSON格式:</b></p>
<blockquote><p>
Ulf_Wendel: @laruence >Thx for the blog. Please note, mysqlnd_ms config format was changed in 1.1.0. Now JSON based
</p></blockquote>
<p>   所以新的配置应该类似于如下格式:</p>
<pre name="code"  class="sh_json"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
{
    &quot;myapp&quot;: {
        &quot;master&quot;: {
            &quot;master_0&quot;: {
                &quot;host&quot;: &quot;localhost&quot;,
                &quot;socket&quot;: &quot;\/tmp\/mysql.sock&quot;
            }
        },
        &quot;slave&quot;: {
            &quot;slave_0&quot;: {
                &quot;host&quot;: &quot;192.168.2.27&quot;,
                &quot;port&quot;: &quot;3306&quot;
            }
        }
    }
}
</pre>
<p>   链接方式修改如下:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
/* Load balanced following &quot;myapp&quot; section rules from the plugins config file */
$mysqli = new mysqli(&quot;myapp&quot;, &quot;username&quot;, &quot;password&quot;, &quot;database&quot;);
$pdo = new PDO('mysql:host=myapp;dbname=database', 'username', 'password');
$mysql = mysql_connect(&quot;myapp&quot;, &quot;username&quot;, &quot;password&quot;);
?&gt;
</pre>
<p>   然后就和你之前一样的来开发了. </p>
<p>   如果希望获得更多信息, 可以参看: <a href="http://php.net/mysqlnd_ms" >http://php.net/mysqlnd_ms</a><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_ini.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_ini.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_json.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script></p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/10/05/2192.html" >2011/10/06</a>, 风起 writes: 不错, 读写分离这点很需要</li><li><a href="http://www.laruence.com/2011/10/05/2192.html" >2011/10/07</a>, <a href="http://baloyou.gotoip55.com/archives/433"  rel="external nofollow"  class="url" >mysqlnd插件mysqlnd_ms的介绍 | 风雪之隅 - 候鸟的博客</a> writes: [...] 通过mysqlnd插件mysqlnd_ms的介绍 | 风雪之隅.      wordpress 源码解读 (1) [...]</li><li><a href="http://www.laruence.com/2011/10/05/2192.html" >2011/10/09</a>, <a href="http://xiaobin.net"  rel="external nofollow"  class="url" >Robin</a> writes: 请问鸟哥有在生产环境使用么？

一直在关注mysqlnd_ms，不过发现从统计数据来看（iva http://url.cn/0DdMJr）下载的人并不多，不太敢贸然使用。

另外也关注mysql proxy，但是问题好像也不少(via http://url.cn/1r9DR5)</li><li><a href="http://www.laruence.com/2011/10/05/2192.html" >2011/10/10</a>, <a href="http://www.6pima.cn"  rel="external nofollow"  class="url" >中山网站建设</a> writes: 不错哟，学习一下</li><li><a href="http://www.laruence.com/2011/10/05/2192.html" >2011/11/19</a>, 深空 writes: 不知道能否很好识别事务</li><li><a href="http://www.laruence.com/2011/10/05/2192.html" >2011/11/25</a>, <a href="http://www.cnxct.com/some-errors-on-compile-php-5-3-8-with-pdo_mysql-and-mysqlnd/"  rel="external nofollow"  class="url" >php5.3.8中编译pdo_mysql的艰难历程 | CNXCT小组的博客</a> writes: [...] 这里是将pdo_mysql作为一个拓展引入使用的。在php5.3中，PHP开发组把mysqlnd作为默认的连接MYSQL的数据库驱动来使用，据官方描述，节省内存40%，速度更快，当然或许是为了解决许可协议的问题。详情见：mysqlnd插件mysqlnd_ms的介绍。 两种方法都可以，运维同事都尝试了，由于时间关系，他们没做过多的尝试研究，就转向更紧急的项目了。 [...]</li></ul><hr/><h2>Related posts:</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2008/09/20/523.html"  rel="bookmark"  title="Permanent Link: PHP5.3 α2初体验" >PHP5.3 α2初体验</a></li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/02/2515.html"  title="我们什么时候应该使用异常?" >我们什么时候应该使用异常?</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li><li><a href="http://www.laruence.com/2012/01/11/2482.html"  title="PHP的历史" >PHP的历史</a></li><li><a href="http://www.laruence.com/2012/01/10/2469.html"  title="如何设置一个严格30分钟过期的Session" >如何设置一个严格30分钟过期的Session</a></li><li><a href="http://www.laruence.com/2012/01/07/2453.html"  title="2012年1月全球www网站技术报告" >2012年1月全球www网站技术报告</a></li><li><a href="http://www.laruence.com/2011/12/30/2440.html"  title="PHP5.2.*防止Hash冲突拒绝服务攻击的Patch" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch</a></li><li><a href="http://www.laruence.com/2011/12/30/2435.html"  title="PHP数组的Hash冲突实例" >PHP数组的Hash冲突实例</a></li><li><a href="http://www.laruence.com/2011/12/29/2412.html"  title="通过构造Hash冲突实现各种语言的拒绝服务攻击" >通过构造Hash冲突实现各种语言的拒绝服务攻击</a></li><li><a href="http://www.laruence.com/2011/12/06/2381.html"  title="更简单的重现PHP Core的调用栈" >更简单的重现PHP Core的调用栈</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/10/05/2192.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>和一朋友对话有感</title>
		<link>http://www.laruence.com/2011/09/30/2187.html</link>
		<comments>http://www.laruence.com/2011/09/30/2187.html#comments</comments>
		<pubDate>Fri, 30 Sep 2011 06:34:10 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[转载]]></category>
		<category><![CDATA[随笔]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2187</guid>
		<description><![CDATA[和一个朋友的对话,  他谈到了一些想法, 我觉得有必要和大家分享一下. ]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>本文地址: <a href="http://www.laruence.com/2011/09/30/2187.html"  title="Permanet Link to 和一朋友对话有感" >http://www.laruence.com/2011/09/30/2187.html</a></li>
<li>转载文章</li>
</ul></div>
<p>  朋友:  你知道你的 nginx+php  pathinfo的问题的那文章, 我看了多少遍吗？ </p>
<p>  我:  &#8230;..  看了多少遍&#8230;</p>
<p>  朋友:   从去年这个问题出现，到我写那个运维开发安全的PPT，我看了不少于50遍吧。</p>
<p>  我:　&#8230;..　　你看那么多遍干啥,,,.</p>
<p>  朋友：不是看一遍就能读懂的。</p>
<p>  我:　　是我写的不明白? -_#　　汗,,你看吧, 我就说我不能写东西..</p>
<p>  朋友： 不是。 前置知识需求太多。</p>
<p>  我:   哦, 呵呵. 那对你有好处啊, 嘿嘿</p>
<p>  朋友:  CGI规范我读了好几遍(PATH_INFO QUERY_STRING这几个章节)。  我最近看了《暗时间》，里面提到几点。我觉得有共鸣: <b>别人写的文章，初次看了，觉得“哦，原来是这么回事”。当有这种感慨的时候，一般就是根本没有真正读懂这文章。</b></p>
<p>  我:   en,搞技术的, 还是要多多追根究底下;)</p>
<p>  朋友:   <b>当后来直到自己真正动手去做这些相关问题的时候，回头再认真看这文章时，才有更深入的理解，发现更多当初压根没在意的术语，关键词。 再去搜这些术语、关键词的资料，熟悉这些之后，再回头看这文章，才有真正的初步了解。 直到对这文章有自己的看法，那才是真正的读懂了。</b></p>
<p>  我:  恩,   这是很好的品质</p>
<p>  朋友:  对再权威的人的文章，能产生质疑了，那才真正的读这文章了。 虽然我还不能对你的文章产生质疑目前。 哈哈。</p>
<p>  我: 对的. 没有永恒的真理,  你说的很有道理, 我忍不住要分享下</p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/09/30/2187.html" >2011/09/30</a>, <a href="http://walu.sinaapp.com"  rel="external nofollow"  class="url" >walu</a> writes: 这篇文章比技术文章还有价值。如果说鸟哥以前在授人以鱼，现在则开始授人以渔了。</li><li><a href="http://www.laruence.com/2011/09/30/2187.html" >2011/09/30</a>, ourac writes: 是不是CFC4N？</li><li><a href="http://www.laruence.com/2011/09/30/2187.html" >2011/10/05</a>, <a href="http://hi.baidu.com/u2solu"  rel="external nofollow"  class="url" >solu</a> writes: 对呀，读技术文章真的不容易。当发现一种陌生的技术或者一个陌生的术语就必须追查一下，然后就越来越远越来越远，至于最后去了多远，这个嘛就要看每个人的积累和水平了。反正我常常去到很遥远的地方，呵呵，很多知识没掌握!</li><li><a href="http://www.laruence.com/2011/09/30/2187.html" >2011/10/07</a>, <a href="http://www.fising.cn"  rel="external nofollow"  class="url" >fising</a> writes: 说的很有道理啊。不知道我不知道，知道我不知道，知道我知道，不知道我知道。</li><li><a href="http://www.laruence.com/2011/09/30/2187.html" >2011/10/08</a>, localtest writes: 对作者的谈话有同感，另外对评论“当发现一种陌生的技术或者一个陌生的术语就必须追查一下，然后就越来越远越来越远，至于最后去了多远，这个嘛就要看每个人的积累和水平了”也很有同感！</li><li><a href="http://www.laruence.com/2011/09/30/2187.html" >2011/10/20</a>, <a href="http://www.di15.com/"  rel="external nofollow"  class="url" >十五博客</a> writes: 读文章，直到自己心中有数，甚至是自己能写出来，那样才算真正读懂了。读别人技术文章是给自己用的，重在是否读懂而非读多少遍。</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Random Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/10/10/2229.html"  title="函数类型提示(Callable typehint)" >函数类型提示(Callable typehint)</a></li><li><a href="http://www.laruence.com/2011/12/06/2381.html"  title="更简单的重现PHP Core的调用栈" >更简单的重现PHP Core的调用栈</a></li><li><a href="http://www.laruence.com/2008/07/16/227.html"  title=" MySQL也真是让人郁闷(关于子查询中使用limit)" > MySQL也真是让人郁闷(关于子查询中使用limit)</a></li><li><a href="http://www.laruence.com/2008/04/17/110.html"  title="页面乱码问题根源浅析" >页面乱码问题根源浅析</a></li><li><a href="http://www.laruence.com/2009/09/08/1076.html"  title="深入理解Javascript之this关键字" >深入理解Javascript之this关键字</a></li><li><a href="http://www.laruence.com/2008/04/14/318.html"  title="PHP实现异步调用方法研究" >PHP实现异步调用方法研究</a></li><li><a href="http://www.laruence.com/2008/04/18/104.html"  title=" C++判断本机的字节序的方法" > C++判断本机的字节序的方法</a></li><li><a href="http://www.laruence.com/2010/05/14/1473.html"  title="使用PHP_UML生成代码的UML图" >使用PHP_UML生成代码的UML图</a></li><li><a href="http://www.laruence.com/2010/05/28/1565.html"  title="PHP错误抑制符(@)导致引用传参失败的Bug" >PHP错误抑制符(@)导致引用传参失败的Bug</a></li><li><a href="http://www.laruence.com/2009/12/05/1172.html"  title="PHP5.2.x + APC的一个bug的定位" >PHP5.2.x + APC的一个bug的定位</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/09/30/2187.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PHP的版本发布历程</title>
		<link>http://www.laruence.com/2011/09/19/2148.html</link>
		<comments>http://www.laruence.com/2011/09/19/2148.html#comments</comments>
		<pubDate>Mon, 19 Sep 2011 12:26:37 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[历史]]></category>
		<category><![CDATA[发布]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2148</guid>
		<description><![CDATA[<p>
   整理了一下, PHP的进化历程,  原文在这里: <a href="https://wiki.php.net/internals/module_api_no">https://wiki.php.net/internals/module_api_no</a>
</p>]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/09/19/2148.html"  title="Permanet Link to PHP的版本发布历程" >http://www.laruence.com/2011/09/19/2148.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
   整理了一下, PHP的进化历程,  原文在这里: <a href="https://wiki.php.net/internals/module_api_no" >https://wiki.php.net/internals/module_api_no</a>
</p>
<table class="inline" >
<tbody>
<tr class="row0" >
<td class="col0" ><strong>Date</strong></td>
<td class="col1" ><strong>Version</strong></td>
</tr>
<tr class="row1" >
<td class="col0 leftalign" > June 8 1995  </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> Tools 1.0 </td>
</tr>
<tr class="row2" >
<td class="col0 leftalign" > Oct 17 1995  </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym>/FI 1.92 </td>
</tr>
<tr class="row3" >
<td class="col0" > Mar 16 1996 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym>/FI 1.99k </td>
</tr>
<tr class="row4" >
<td class="col0" > June 16 1997 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym>/FI 2.0b12 </td>
</tr>
<tr class="row5" >
<td class="col0" > Oct 29 1997 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 3.0a1 </td>
</tr>
<tr class="row6" >
<td class="col0" > Nov 12 1997 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym>/FI 2.0 </td>
</tr>
<tr class="row7" >
<td class="col0 leftalign" > Dec 8 1997  </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 3.0b1 </td>
</tr>
<tr class="row8" >
<td class="col0 leftalign" > Jan 9 1998  </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym>/FI 2.0.1 </td>
</tr>
<tr class="row9" >
<td class="col0 leftalign" > June 6 1998  </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 3.0 </td>
</tr>
<tr class="row10" >
<td class="col0 leftalign" > July 4 1998  </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 3.0.1 </td>
</tr>
<tr class="row11" >
<td class="col0 leftalign" > Mar 1 1999  </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 3.0.7 </td>
</tr>
<tr class="row12" >
<td class="col0" > July 19 1999 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.0b1 </td>
</tr>
<tr class="row13" >
<td class="col0 leftalign" > Jan 1 2000  </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 3.0.13 </td>
</tr>
<tr class="row14" >
<td class="col0" > Oct 21 2000 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 3.0.18 </td>
</tr>
<tr class="row15" >
<td class="col0 leftalign" > May 22 2000  </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.0 </td>
</tr>
<tr class="row16" >
<td class="col0" > Oct 11 2000 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.0.3 </td>
</tr>
<tr class="row17" >
<td class="col0" > Apr 30 2001 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.0.5 </td>
</tr>
<tr class="row18" >
<td class="col0" > June 23 2001 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.0.6 </td>
</tr>
<tr class="row19" >
<td class="col0" > Dec 10 2001 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.1.0 </td>
</tr>
<tr class="row20" >
<td class="col0" > Dec 26 2001 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.1.1 </td>
</tr>
<tr class="row21" >
<td class="col0" > Feb 27 2002 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.1.2 </td>
</tr>
<tr class="row22" >
<td class="col0" > Apr 22 2002 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.2.0 </td>
</tr>
<tr class="row23" >
<td class="col0 leftalign" > May 13 2002  </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.2.1 </td>
</tr>
<tr class="row24" >
<td class="col0" > July 22 2002 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.2.2 </td>
</tr>
<tr class="row25" >
<td class="col0" > Sep  6 2002 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.2.3 </td>
</tr>
<tr class="row26" >
<td class="col0" > Dec 27 2002 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.3.0 </td>
</tr>
<tr class="row27" >
<td class="col0" > Feb 17 2003 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.3.1 </td>
</tr>
<tr class="row28" >
<td class="col0" > May 29 2003 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.3.2 </td>
</tr>
<tr class="row29" >
<td class="col0" > Aug 25 2003 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.3.3 </td>
</tr>
<tr class="row30" >
<td class="col0" > Nov 03 2003 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.3.4 </td>
</tr>
<tr class="row31" >
<td class="col0" > Jul 13 2004 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.0.0 &amp; <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.3.8 </td>
</tr>
<tr class="row32" >
<td class="col0" > Aug 12 2004 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.0.1 </td>
</tr>
<tr class="row33" >
<td class="col0" > Sep 03 2004 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.0.2 </td>
</tr>
<tr class="row34" >
<td class="col0" > Sep 22 2004 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.3.9 </td>
</tr>
<tr class="row35" >
<td class="col0" > Dec 15 2004 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.0.3 &amp; <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.3.10 </td>
</tr>
<tr class="row36" >
<td class="col0" > Mar 31 2005 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.0.4 &amp; <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.3.11 </td>
</tr>
<tr class="row37" >
<td class="col0" > Jul 11 2005 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.4.0 </td>
</tr>
<tr class="row38" >
<td class="col0" > Sep 06 2005 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.0.5 </td>
</tr>
<tr class="row39" >
<td class="col0" > Oct 31 2005 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.4.1 </td>
</tr>
<tr class="row40" >
<td class="col0" > Nov 24 2005 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.1.0 </td>
</tr>
<tr class="row41" >
<td class="col0" > Nov 28 2005 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.1.1 </td>
</tr>
<tr class="row42" >
<td class="col0" > Jan 12 2006 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.1.2 </td>
</tr>
<tr class="row43" >
<td class="col0" > Jan 13 2006 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.4.2 </td>
</tr>
<tr class="row44" >
<td class="col0" > May 01 2006 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.1.3 </td>
</tr>
<tr class="row45" >
<td class="col0" > May 04 2006 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.1.4 </td>
</tr>
<tr class="row46" >
<td class="col0" > Aug 03 2006 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.4.3 </td>
</tr>
<tr class="row47" >
<td class="col0" > Aug 17 2006 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.1.5 &amp; <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.4.4 </td>
</tr>
<tr class="row48" >
<td class="col0" > Aug 24 2006 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.1.6 </td>
</tr>
<tr class="row49" >
<td class="col0" > Nov 02 2006 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.0 </td>
</tr>
<tr class="row50" >
<td class="col0" > Feb 08 2007 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.1 &amp; <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.4.5 </td>
</tr>
<tr class="row51" >
<td class="col0" > Mar 01 2007 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.4.6 </td>
</tr>
<tr class="row52" >
<td class="col0" > May 03 2007 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.2 &amp; <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.4.7 </td>
</tr>
<tr class="row53" >
<td class="col0" > Jun 01 2007 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.3 </td>
</tr>
<tr class="row54" >
<td class="col0" > Aug 30 2007 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.4 </td>
</tr>
<tr class="row55" >
<td class="col0" > Nov 09 2007 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.5 </td>
</tr>
<tr class="row56" >
<td class="col0" > Jan 03 2008 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.4.8 </td>
</tr>
<tr class="row57" >
<td class="col0" > May 01 2008 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.6 </td>
</tr>
<tr class="row58" >
<td class="col0" > Aug 07 2008 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 4.4.9 </td>
</tr>
<tr class="row59" >
<td class="col0" > Dec 04 2008 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.7 </td>
</tr>
<tr class="row60" >
<td class="col0" > Dec 08 2008 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.8 </td>
</tr>
<tr class="row61" >
<td class="col0" > Feb 26 2009 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.9 </td>
</tr>
<tr class="row62" >
<td class="col0" > Jun 18 2009 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.10 </td>
</tr>
<tr class="row63" >
<td class="col0" > Jun 30 2009 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.3.0 </td>
</tr>
<tr class="row64" >
<td class="col0" > Sep 17 2009 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.11 </td>
</tr>
<tr class="row65" >
<td class="col0" > Nov 19 2009 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.3.1 </td>
</tr>
<tr class="row66" >
<td class="col0" > Dec 17 2009 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.12 </td>
</tr>
<tr class="row67" >
<td class="col0" > Feb 25 2010 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.13 </td>
</tr>
<tr class="row68" >
<td class="col0" > Mar 04 2010 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.3.2 </td>
</tr>
<tr class="row69" >
<td class="col0" > Jul 22 2010 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.3.3 &amp; <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.14 </td>
</tr>
<tr class="row70" >
<td class="col0" > Dec 09 2010 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.15 </td>
</tr>
<tr class="row71" >
<td class="col0" > Dec 10 2010 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.3.4 </td>
</tr>
<tr class="row72" >
<td class="col0" > Dec 16 2010 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.16 </td>
</tr>
<tr class="row73" >
<td class="col0" > Jan 06 2011 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.3.5 &amp; <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.2.17 </td>
</tr>
<tr class="row74" >
<td class="col0" > Mar 17 2011 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.3.6 </td>
</tr>
<tr class="row75" >
<td class="col0" > Aug 18 2011 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.3.7 </td>
</tr>
<tr class="row76" >
<td class="col0" > Aug 23 2011 </td>
<td class="col1" > <acronym title="Hypertext Preprocessor" >PHP</acronym> 5.3.8 </td>
</tr>
</tbody>
</table>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/09/19/2148.html" >2011/09/20</a>, <a href="http://zhys9.com"  rel="external nofollow"  class="url" >zhys9</a> writes: 记得刚开始搞PHP时是4.3的时代， 还能经常看到.php3的代码 :D，现在已然是时过境迁咯</li><li><a href="http://www.laruence.com/2011/09/19/2148.html" >2011/09/20</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @zhys9 呵呵, 都快10年了... :)</li><li><a href="http://www.laruence.com/2011/09/19/2148.html" >2011/09/21</a>, wclssdn writes: 刚开始学的时候, 就是PHP5的表示很庆幸~~ 
现在好多人貌似都在用5.2.6吧.... 不知道升级PHP版本会对现有程序造成哪些影响?</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2012/01/11/2482.html"  title="PHP的历史" >PHP的历史</a></li><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/02/2515.html"  title="我们什么时候应该使用异常?" >我们什么时候应该使用异常?</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li><li><a href="http://www.laruence.com/2012/01/10/2469.html"  title="如何设置一个严格30分钟过期的Session" >如何设置一个严格30分钟过期的Session</a></li><li><a href="http://www.laruence.com/2012/01/07/2453.html"  title="2012年1月全球www网站技术报告" >2012年1月全球www网站技术报告</a></li><li><a href="http://www.laruence.com/2011/12/30/2440.html"  title="PHP5.2.*防止Hash冲突拒绝服务攻击的Patch" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch</a></li><li><a href="http://www.laruence.com/2011/12/30/2435.html"  title="PHP数组的Hash冲突实例" >PHP数组的Hash冲突实例</a></li><li><a href="http://www.laruence.com/2011/12/29/2412.html"  title="通过构造Hash冲突实现各种语言的拒绝服务攻击" >通过构造Hash冲突实现各种语言的拒绝服务攻击</a></li><li><a href="http://www.laruence.com/2011/12/06/2381.html"  title="更简单的重现PHP Core的调用栈" >更简单的重现PHP Core的调用栈</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/09/19/2148.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>关于做PHP扩展开发的一些资源</title>
		<link>http://www.laruence.com/2011/09/13/2139.html</link>
		<comments>http://www.laruence.com/2011/09/13/2139.html#comments</comments>
		<pubDate>Tue, 13 Sep 2011 08:14:01 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP extension]]></category>
		<category><![CDATA[开发php扩展]]></category>
		<category><![CDATA[扩展开发]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2139</guid>
		<description><![CDATA[  最近有个感觉, 越来越多的人开始从事PHP扩展开发的工作(越来越多的人来问问题了, 呵呵)

   在这里先说声抱歉, 有的时候, 有的同学的邮件进了垃圾邮件没有办法及时回复.

   为了方便大家, 我在这里罗列一些可能用到的资源.]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/09/13/2139.html"  title="Permanet Link to 关于做PHP扩展开发的一些资源" >http://www.laruence.com/2011/09/13/2139.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
   最近有个感觉, 越来越多的人开始从事PHP扩展开发的工作(越来越多的人来问问题了, 呵呵)</p>
<p>   在这里先说声抱歉, 有的时候, 有的同学的邮件进了垃圾邮件没有办法及时回复.</p>
<p>   为了方便大家, 我在这里罗列一些可能用到的资源.</p>
<p>   1. 首先, 要推荐一本书 《Extending and Embedding PHP》,  如果你有时间, 我建议你在做之前好好读读这本书(目前没有中文版)</p>
<p>   2. Google/Baidu 这个就不用多说了吧</p>
<p>   3. PHP的源代码中,包含了一些编写良好的&#8221;例子&#8221;, 都在ext/目录下, 绝大部分Zend_API的使用, 都在里面有例子.</p>
<p>   4. pecl-dev at lists.php.net 这个邮件组是扩展开发的交流邮件组, 如果你实在是Google/baidu不到你的问题的答案, 可以发邮件到这个邮件组提问, 不过, 一般来说, 要有耐心等待回复(大部分人和我们有15个小时的时差, 当然, 如果我看到了, 我会尽量回复)</p>
<p>   5. efnet #php.pecl 这里聚集了pecl开发者,  你也可以来这里提问(我整天都在上面), 不过这里只能说英文,  另外提问的时候要注意不要直接粘贴代码, 而应该使用pastebin之类的工具(所以还是建议大家发邮件到pecl-dev)</p>
<p>   6. 尽量编写一些phpt测试用例(phpt的写法在每个标准扩展下面都有例子, tests目录下), 来测试你的扩展.</p>
<p>   7. 测试的时候用&#8211;enable-debug编译PHP, 来测试你的扩展, 你要做到执行你的扩展逻辑, 不输出任何错误信息</p>
<p>   8. 使用valgrind检测内存泄露.</p>
<p>  希望对大家有帮助. </p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/09/13</a>, <a href="http://www.startfeel.com"  rel="external nofollow"  class="url" >Ray</a> writes: 鸟哥。。。书名呢？</li><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/09/13</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: 好了, 呵呵, 换成书名号了...</li><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/09/13</a>, Qianfeng writes: 鸟哥，我想知道你的，开发桌面是什么系统？。。

还有日常使用的桌面是否同一个~~</li><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/09/13</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @Qianfeng 我自己用windows, 虚拟机是Linux, 在Linux下开发</li><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/09/13</a>, <a href="http://blog.iterse.com"  rel="external nofollow"  class="url" >iterse's blog</a> writes: 鸟哥，V5！</li><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/09/14</a>, <a href="http://walu.sinaapp.com"  rel="external nofollow"  class="url" >walu</a> writes: 《Extending and Embedding PHP》我正在翻译，项目地址：http://phpbook.sinaapp.com 如果鸟哥偶尔有空，还请帮忙斧正。:-)</li><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/09/14</a>, 早起的菜鸟 writes: 鸟哥 你是不是那个写私房菜的鸟哥啊？都是大神啊！我也取了鸟的名字，希望能够沾沾你们的才气</li><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/09/14</a>, <a href="http://010blog.sinaapp.com"  rel="external nofollow"  class="url" >Me.strone</a> writes: 没注意，原来是传说中的鸟哥啊……看了你写的那两个私房菜，很不错。希望多多出好书！我们就多多向你学习了。</li><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/09/14</a>, <a href="http://www.laruence.com/"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @walu 我看了下,翻译的挺好, 不过有一点, 就是那本书成书已经好几年了, 最近PHP改变较多, 尤其是5.4, 底层结构变化也比较多, 如果忠实翻译还好, 否则可能要考虑新加入的东西:)</li><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/09/14</a>, <a href="http://www.laruence.com/"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @早起的菜鸟 @Me.strone 诶, 私房菜的鸟哥是台湾的, 搞Linux的, :&lt;</li><li><a href="http://www.laruence.com/2011/09/13/2139.html" >2011/10/10</a>, <a href="http://blog.thinkinlamp.com/?p=776"  rel="external nofollow"  class="url" >Thinking In LAMP Blog &raquo; Blog Archive &raquo; PHP每月通讯（2011年10月）</a> writes: [...] http://www.laruence.com/2011/09/13/2139.html 　　关于做PHP扩展开发的一些资源 [...]</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2009/04/28/719.html"  title="用C/C++扩展你的PHP" >用C/C++扩展你的PHP</a></li><li><a href="http://www.laruence.com/2009/08/18/1042.html"  title="保证PHP扩展的依赖关系" >保证PHP扩展的依赖关系</a></li><li><a href="http://www.laruence.com/2008/04/16/19.html"  title="编写提供对象给PHP使用的Module" >编写提供对象给PHP使用的Module</a></li><li><a href="http://www.laruence.com/2011/07/02/2102.html"  title="Zend Parameters Parser新增类型描述符介绍" >Zend Parameters Parser新增类型描述符介绍</a></li><li><a href="http://www.laruence.com/2011/06/19/2047.html"  title="PLua &#8211; Lua for PHP" >PLua &#8211; Lua for PHP</a></li><li><a href="http://www.laruence.com/2010/09/04/1736.html"  title="Yaf-一个PHP扩展实现的PHP框架" >Yaf-一个PHP扩展实现的PHP框架</a></li><li><a href="http://www.laruence.com/2008/08/16/301.html"  title="扩展PHP[Extending PHP](一)" >扩展PHP[Extending PHP](一)</a></li><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/02/2515.html"  title="我们什么时候应该使用异常?" >我们什么时候应该使用异常?</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/09/13/2139.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>分享个开心的事情</title>
		<link>http://www.laruence.com/2011/08/09/2136.html</link>
		<comments>http://www.laruence.com/2011/08/09/2136.html#comments</comments>
		<pubDate>Tue, 09 Aug 2011 03:21:52 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[随笔]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2136</guid>
		<description><![CDATA[<p>
      Hi,  从我做PHP开始到现在, 已经差不多有6年的时间了.

      在6月份的时候, 我加入了PECL官方扩展开发小组.
  
      也就在前天, 我终于加入了PHP开发小组.  这个也算是一个阶段性的被肯定吧..

      做开源事业, 真的是很单纯,  难以抑制的喜悦, 想和大家分享.

      回顾这6年, 兴趣是我最大的动力,  thanks all.
</p>
    ]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/08/09/2136.html"  title="Permanet Link to 分享个开心的事情" >http://www.laruence.com/2011/08/09/2136.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
      Hi,  从我做PHP开始到现在, 已经差不多有6年的时间了.</p>
<p>      在6月份的时候, 我加入了PECL官方扩展开发小组.</p>
<p>      也就在前天, 我终于加入了PHP开发小组.  这个也算是一个阶段性的被肯定吧..</p>
<p>      做开源事业, 真的是很单纯,  难以抑制的喜悦, 想和大家分享.</p>
<p>      回顾这6年, 兴趣是我最大的动力,  thanks all.</p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, Shiwei Hu writes: 沙发</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://rossobe.com"  rel="external nofollow"  class="url" >Amaranth</a> writes: 一个字,恭喜</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, zorro writes: 特地来此顶哥</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://www.feiyan.info"  rel="external nofollow"  class="url" >飞晏</a> writes: 恭喜前辈~</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://dev.5iplaynow.com"  rel="external nofollow"  class="url" >Mrzeta</a> writes: 恭喜 ~~</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, 劣猫 writes: 恭喜。</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, chibs writes: 恭喜！
从你的文章中学到很多知识。继续加油！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, horseluke writes: 恭喜</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://www.alexthink.com"  rel="external nofollow"  class="url" >alex</a> writes: 恭喜和膜拜～～</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://roga.tw"  rel="external nofollow"  class="url" >roga</a> writes: 恭喜!</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://blog.webfuns.net"  rel="external nofollow"  class="url" >tomheng</a> writes: 前辈，榜样！！！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, jackywdx writes: 恭喜啊！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, tcdona writes: 我觉得做开源事业的人很伟大</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, 韩天峰 writes: 了不起！向你学习。</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, walu writes: 恭喜恭喜～
终于有国人可以正大光明的往php源码里写
//wolegequ,geiliable了，o(∩∩)o...哈哈</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://www.zhangabc.com"  rel="external nofollow"  class="url" >Er.Z</a> writes: …… 
回顾这6年, 兴趣是我最大的动力, thanks all.
……

无限羡慕。</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://www.zivee.cn/"  rel="external nofollow"  class="url" >zivee</a> writes: 为你高兴，支持，学习榜样</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, icehox writes: 恭喜
多分享啊...</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, Nathan writes: 期待你能出本书，系统的介绍PHP的实现。</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, xinquan writes: 恭喜!</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, likeh2o writes: 必须恭喜！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, 雪心 writes: 恭喜恭喜，最近差不多翻遍了你的blog
受益良多</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://liulixiang.info"  rel="external nofollow"  class="url" >R2D2</a> writes: 恭喜恭喜！

ps:一不小心进来了，发现世界好小</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://www.todeer.com"  rel="external nofollow"  class="url" >logbird</a> writes: 恭喜鸟哥了 哈哈 以后还得向您学习。</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://www.cnxct.com"  rel="external nofollow"  class="url" >CFC4N</a> writes: 恭喜鸟哥。希望我6年之后，有鸟哥一半的造诣。</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, <a href="http://zhys9.com"  rel="external nofollow"  class="url" >zhys9</a> writes: 恭喜鸟哥了～</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, Neagle writes: 签名该改下了.  辛卯年再领得半职于PECL。 ...</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/09</a>, hibin writes: 鸟哥太棒了，一直都是学习的榜样</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/10</a>, <a href="http://hi.baidu.com/blue5tar_"  rel="external nofollow"  class="url" >blue5tar</a> writes: 向鸟哥学习！！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/10</a>, bingchao writes: 鸟哥V5</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/10</a>, starsm writes: v5</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/10</a>, silentime writes: 赞鸟哥！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/10</a>, <a href="http://sychen.org"  rel="external nofollow"  class="url" >sychen</a> writes: 祝贺！赞一个~</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/10</a>, <a href="http://adamlu.net"  rel="external nofollow"  class="url" >adam.lu</a> writes: 恭喜你。真希望我也能有这么一天：）</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/10</a>, eve writes: 鸟哥出书吧~~~我们翘首期盼~~~</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/11</a>, rwl writes: 希望中国phper 多贡献 开源，php.我们也可以最早接触php相关新知识。</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/11</a>, zhuqian writes: 做喜欢的事情，真的开心！支持中国PHP第一人！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/11</a>, <a href="http://pplxh.cublog.cn"  rel="external nofollow"  class="url" >pplxh</a> writes: 鸟哥好厉害！加油～～～～你和我一样哦，兴趣是我一直走到今天最大的动力～～～～！！永远顶你哦！！！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/12</a>, <a href="http://blog.solrex.org"  rel="external nofollow"  class="url" >Solrex</a> writes: 向鸟哥学习！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/12</a>, <a href="http://blog.iterse.com"  rel="external nofollow"  class="url" >Iterse's blog</a> writes: 鸟哥，威武，顶！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/12</a>, <a href="http://zcooler.com"  rel="external nofollow"  class="url" >zcooler</a> writes: 呵呵，恭喜～</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/13</a>, meixr writes: 顶楼主 恭喜</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/13</a>, <a href="http://fengbloger.net"  rel="external nofollow"  class="url" >feng</a> writes: 向前辈学习！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/14</a>, rainkid writes: 呵呵，恭喜～</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/14</a>, <a href="http://blog.bjmayor.com"  rel="external nofollow"  class="url" >bjmayor</a> writes: 友情支持!</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/15</a>, <a href="http://dev.meettea.com"  rel="external nofollow"  class="url" >shiny</a> writes: 猛人</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/17</a>, oneroom writes: 向偶像致敬</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/18</a>, <a href="http://blog.iterse.com"  rel="external nofollow"  class="url" >iterse's blog</a> writes: 恭喜，恭喜！</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/18</a>, 王洛堇 writes: 这么简短的文章，还有48个回复。。。啧啧啧</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/18</a>, Bin writes: 鸟哥牛啊~ 求带我做项目~~ T_T</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/19</a>, <a href="http://www.chengde123.com"  rel="external nofollow"  class="url" >承德旅游</a> writes: 恭喜啦 作为一个开发者，能被周围朋友和同行肯定认可，想必是对大的幸福    终修正果</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/22</a>, <a href="http://blog.i1602.com"  rel="external nofollow"  class="url" >Zhaolei</a> writes: 你博客的粉丝。 祝贺你。</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/23</a>, Youxiu writes: 发现博主在PHP官网的信息了 : http://people.php.net/user.php?username=laruence

膜拜!</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/23</a>, 神仙 writes: php 里有没可能加个类似 python 的 yield 语法？</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/24</a>, <a href="http://lianq.net"  rel="external nofollow"  class="url" >lkk</a> writes: 牛人啊，膜拜</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/08/27</a>, Qianfeng writes: 给力啊！我也要好好学C!</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/09/05</a>, jon writes: 祝贺，感谢分享你的php经验，学到很多东西</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/09/13</a>, <a href="http://www.chuanyi.cc/blog/"  rel="external nofollow"  class="url" >习小衣</a> writes: 确实是值得开心的事情啊~

祝贺祝贺~</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/10/20</a>, <a href="http://deloz.net"  rel="external nofollow"  class="url" >Deloz</a> writes: 顶,向您学习</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/10/20</a>, <a href="http://www.iamle.com"  rel="external nofollow"  class="url" >wwek</a> writes: 恭喜。希望php未来更好·</li><li><a href="http://www.laruence.com/2011/08/09/2136.html" >2011/11/01</a>, gan writes: 恭喜，同时也非常羡慕，我们被英语给限制住了，哎。</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Random Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/07/14/2115.html"  title="Zend引擎的优化" >Zend引擎的优化</a></li><li><a href="http://www.laruence.com/2008/07/01/322.html"  title="在Gvim中使用和Vim一样的配色方案" >在Gvim中使用和Vim一样的配色方案</a></li><li><a href="http://www.laruence.com/2008/04/18/104.html"  title=" C++判断本机的字节序的方法" > C++判断本机的字节序的方法</a></li><li><a href="http://www.laruence.com/2009/05/18/809.html"  title="使用JS做文档处理" >使用JS做文档处理</a></li><li><a href="http://www.laruence.com/2009/04/21/680.html"  title="phpDocumentor" >phpDocumentor</a></li><li><a href="http://www.laruence.com/2009/12/09/1180.html"  title="isset和is_null的不同" >isset和is_null的不同</a></li><li><a href="http://www.laruence.com/2007/12/11/122.html"  title="Perl的特别之处" >Perl的特别之处</a></li><li><a href="http://www.laruence.com/2008/05/01/106.html"  title="汉字和Unicode码(utf-8)之间的转换(Pack/Unpack)" >汉字和Unicode码(utf-8)之间的转换(Pack/Unpack)</a></li><li><a href="http://www.laruence.com/2011/10/10/2212.html"  title="Array dereferencing" >Array dereferencing</a></li><li><a href="http://www.laruence.com/2009/09/27/1123.html"  title="关于Javascript的俩个有趣的探讨" >关于Javascript的俩个有趣的探讨</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/08/09/2136.html/feed</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
		<item>
		<title>Plua进入Pecl</title>
		<link>http://www.laruence.com/2011/08/04/2131.html</link>
		<comments>http://www.laruence.com/2011/08/04/2131.html#comments</comments>
		<pubDate>Thu, 04 Aug 2011 05:28:49 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP Extension]]></category>
		<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[pecl]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2131</guid>
		<description><![CDATA[  一个月以前, 我开发了一个php扩展(<a href="http://www.laruence.com/2011/06/19/2047.html"> PLua – Lua for PHP </a>), 支持在PHP中调用Lua脚本
  
    后续, 发现在pecl中有一个类似的扩展, lua

    在和lua的作者johannes, Andreas讨论过以后,  我们一致认为, 应该只保留一个lua扩展.

    考虑到Plua的设计更加符合PHP思维习惯, 功能上也比lua要更加丰富, 大家就一致决定把plua作为新的lua标准扩展, 当然plua也会借鉴lua现在的一些优点.

    目前plua已经整合到pecl lua的svn中,  等和johannes确认以后, 就会发布release: <a href="http://pecl.php.net/package/lua">Lua</a>
]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/08/04/2131.html"  title="Permanet Link to Plua进入Pecl" >http://www.laruence.com/2011/08/04/2131.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
    一个月以前, 我开发了一个php扩展(<a href="http://www.laruence.com/2011/06/19/2047.html" > PLua – Lua for PHP </a>), 支持在PHP中调用Lua脚本</p>
<p>    后续, 发现在pecl中有一个类似的扩展, lua</p>
<p>    在和lua的作者johannes, Andreas讨论过以后,  我们一致认为, 应该只保留一个lua扩展.</p>
<p>    考虑到Plua的设计更加符合PHP思维习惯, 功能上也比lua要更加丰富, 大家就一致决定把plua作为新的lua标准扩展, 当然plua也会借鉴lua现在的一些优点.</p>
<p>    目前plua已经整合到pecl lua的svn中,  等和johannes确认以后, 就会发布release: <a href="http://pecl.php.net/package/lua" >Lua</a></p>
<p>    后续Plua的project将不再维护, 相关文档也将在lua中重新编写&#8230;</p>
<p>    Btw: 这也是我的第二个PECL扩展..</p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/08/04/2131.html" >2011/08/04</a>, walu writes: 呵呵，鸟哥出品，必属精品～

小弟正在努力学习PHP内核的这个东东，鸟哥你就是偶像+榜样啊</li><li><a href="http://www.laruence.com/2011/08/04/2131.html" >2011/08/09</a>, rwl writes: 支持下，不简单。</li><li><a href="http://www.laruence.com/2011/08/04/2131.html" >2011/08/12</a>, <a href="http://blog.iterse.com"  rel="external nofollow"  class="url" >Iterse's blog</a> writes: 学习，学习！</li><li><a href="http://www.laruence.com/2011/08/04/2131.html" >2011/09/21</a>, rman writes: Would you be so kind - compile php win32 extension dll, and upload it to googlecode, please..</li><li><a href="http://www.laruence.com/2011/08/04/2131.html" >2011/09/27</a>, <a href="http://www.zwsos.com"  rel="external nofollow"  class="url" >sdk</a> writes: 鸟哥，，是台湾那个鸟哥么，LINUX学习的那个么</li></ul><hr/><h2>Related posts:</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/06/19/2047.html"  rel="bookmark"  title="Permanent Link: PLua &#8211; Lua for PHP" >PLua &#8211; Lua for PHP</a></li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/06/19/2047.html"  title="PLua &#8211; Lua for PHP" >PLua &#8211; Lua for PHP</a></li><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/02/2515.html"  title="我们什么时候应该使用异常?" >我们什么时候应该使用异常?</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li><li><a href="http://www.laruence.com/2012/01/11/2482.html"  title="PHP的历史" >PHP的历史</a></li><li><a href="http://www.laruence.com/2012/01/10/2469.html"  title="如何设置一个严格30分钟过期的Session" >如何设置一个严格30分钟过期的Session</a></li><li><a href="http://www.laruence.com/2012/01/07/2453.html"  title="2012年1月全球www网站技术报告" >2012年1月全球www网站技术报告</a></li><li><a href="http://www.laruence.com/2011/12/30/2440.html"  title="PHP5.2.*防止Hash冲突拒绝服务攻击的Patch" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch</a></li><li><a href="http://www.laruence.com/2011/12/30/2435.html"  title="PHP数组的Hash冲突实例" >PHP数组的Hash冲突实例</a></li><li><a href="http://www.laruence.com/2011/12/29/2412.html"  title="通过构造Hash冲突实现各种语言的拒绝服务攻击" >通过构造Hash冲突实现各种语言的拒绝服务攻击</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/08/04/2131.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Zend引擎的优化</title>
		<link>http://www.laruence.com/2011/07/14/2115.html</link>
		<comments>http://www.laruence.com/2011/07/14/2115.html#comments</comments>
		<pubDate>Thu, 14 Jul 2011 03:13:38 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP源码分析]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php5.4]]></category>
		<category><![CDATA[PHP5.4新特性]]></category>
		<category><![CDATA[zend vm]]></category>
		<category><![CDATA[zend引擎]]></category>
		<category><![CDATA[优化]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2115</guid>
		<description><![CDATA[ 在PHP 5.4的更新list上, 有一句: 提升了Zend引擎的性能, 减少了内存占用.

    那么, 到底是怎么提升的呢?
]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/07/14/2115.html"  title="Permanet Link to Zend引擎的优化" >http://www.laruence.com/2011/07/14/2115.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
    在PHP 5.4的更新list上, 有一句: 提升了Zend引擎的性能, 减少了内存占用.</p>
<p>    那么, 到底是怎么提升的呢?</p>
<h3>避免不必要的Hashtable</h3>
<p>   我们知道在PHP中, 类的属性/静态属性/常量, 都是保存在Hashtable中的,  而在以前, 即使一个类没有申明属性/静态属性/常量, Zend引擎也会为他们分配Hashtable.</p>
<p>    而在现在,  这个过程被优化了,  只有在有元素的时候才会分配Hashtable.</p>
<p>    这样就避免一些emalloc/efree操作, 减少一些内存占用.</p>
<h3>四元式优化</h3>
<p>    在PHP中, 真正执行的是Opcodes,  一个Opcodes包含3个固定的操作数,  result, left, right,  在以前, 这三个操作数每一个都包含一个zval, 即使根本用不到的时候, 比如没有右操作数的时候,  还会为右操作数分配一个zval.</p>
<p>    而在现在,  所有的操作数将不再直接包含zval,  而是包含一个literal table的指针,  每一个op array都会包含一个literal table.<br/>
    并且znode也做了相应的调整.  </p>
<p>    这样一来, 也能减少一些内存占用. 从之前的(32位操作系统)一个opcode占用72byte, 到现在的28byte.</p>
<p>    另外, 对于string,  literal table还会保存一份这个string的预先计算的hash值, 避免了在运行时多次计算. 从而提高一部分性能.</p>
<h3>字面字符串</h3>
<p>    就好像C语言中, 代码中的字面字符串, 会保存在一个固定段内(数据段), 在整个执行时期, 这些字符串都是常量字符串,不能被修改,不能被free.</p>
<p>    PHP也借鉴了这样的思想, 提出一个Internal string的概念, 在PHP代码中的字面量字符串, 将会一次分配, 并前在整个执行期都不能被修改. </p>
<p>    PHP在copy_zval, free zval等操作的时候, 会对internal string特别处理, 避免不必要的free和复制.</p>
<p>    并且这些字面量字符串的hash值将会被预先计算,  这样一来,  对于字符串比较 ==, 以及hashtable中的hash计算来说, 都可以直接使用这个预先计算的hash值, 从而能提高一部分性能.</p>
<h3>其他</h3>
<p>     当然,  还有很多优化点, 比如优化了opcode, 减少了一些不必要的opcodes,  在此就不一一赘述了. </p>
<h3>对比</h3>
<p>下面是PHP开发小组内部测试的一些数据:</p>
<p>原生PHP, 没有Opcode Cache:</p>
<table>
<tbody>
<tr>
<th>                       </th>
<th> php-trunk </th>
<th> patched </th>
<th> inprovement </th>
</tr>
<tr>
<td> bench.php (sec)       </td>
<td>      4.31 </td>
<td>    3.49 </td>
<td>         19% </td>
</tr>
<tr>
<td> micro_bench.php (sec) </td>
<td>     19.78 </td>
<td>   14.63 </td>
<td>         26% </td>
</tr>
</tbody>
</table>
<p>一些实际的应用:</p>
<table>
<tbody>
<tr>
<th>                     </th>
<th> php-trunk </th>
<th> pathced </th>
<th> improvement </th>
</tr>
<tr>
<td> blog (req/sec)      </td>
<td>      59.3 </td>
<td>    66.2 </td>
<td>         12% </td>
</tr>
<tr>
<td> drupal (req/sec)    </td>
<td>    1073.9 </td>
<td>  1084.8 </td>
<td>          1% </td>
</tr>
<tr>
<td> fw (req/sec)        </td>
<td>     105.3 </td>
<td>   111.8 </td>
<td>          6% </td>
</tr>
<tr>
<td> hello (req/sec)     </td>
<td>    5362.5 </td>
<td>  5351.4 </td>
<td>          0% </td>
</tr>
<tr>
<td> qdig (req/sec)      </td>
<td>     243.4 </td>
<td>   253.7 </td>
<td>          4% </td>
</tr>
<tr>
<td> typo3 (req/sec)     </td>
<td>     355.3 </td>
<td>   382.6 </td>
<td>          8% </td>
</tr>
<tr>
<td> wordpress (req/sec) </td>
<td>     101.8 </td>
<td>   108.5 </td>
<td>          7% </td>
</tr>
<tr>
<td> xoops (req/sec)     </td>
<td>      70.3 </td>
<td>    78.5 </td>
<td>         12% </td>
</tr>
<tr>
<td> scrum (req/sec)     </td>
<td>      86.5 </td>
<td>   104.2 </td>
<td>         20% </td>
</tr>
</tbody>
</table>
<p>     从这些数据来看, 性能提升还是很明显的..</p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/07/14</a>, <a href="http://www.xoopsengine.org"  rel="external nofollow"  class="url" >D.J.</a> writes: 谢谢Laruence的深度解析。
Benchmark这部分有公开的文章描述么？</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/07/14</a>, cute writes: 好消息啊！
在PHP代码中的字面量字符串, 将会一次分配, 并前再整个执行器都不能被修改.
潜在？</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/07/14</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @D.J. 没有公开的数据, 因为只是作为RFC的辅助说明数据.</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/07/14</a>, Locke writes: 并前再整个执行器都不能被修改.
=======================
并且在整个执行期都不能被修改。</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/07/14</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @Locke  thanks, 呵呵, 我是有名的别字大王....</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/09/07</a>, <a href="http://warpigallen.sinaapp.com/?p=50"  rel="external nofollow"  class="url" >warpig&#039;s blog &raquo; [转]PLua – Lua for PHP</a> writes: [...] 本文地址: http://www.laruence.com/2011/07/14/2115.html [...]</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/09/24</a>, <a href="http://lilazhou.wordpress.com/2011/09/23/222/"  rel="external nofollow"  class="url" >傻子日志</a> writes: [...] Zend&#24341;&#25806;&#30340;&#20248;&#21270; [...]</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/10/04</a>, <a href="http://read.osser.me/?p=294"  rel="external nofollow"  class="url" >PHP正则之递归匹配 | love googlereader</a> writes: [...] Zend&#24341;&#25806;&#30340;&#20248;&#21270; [...]</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/10/09</a>, funlake writes: 为啥没有joomla1.7的测试结果.</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/10/25</a>, Xorcerer writes: 谢谢你的分析。
另外，第二张，既最后一张表格的 “pathced” 也许应为 “patched”</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/11/01</a>, gan writes: 兄弟乃PHP大牛，我会经常关注你的网站，希望多多发表，多多透露，我们也会多多提关于PHP的建议。</li><li><a href="http://www.laruence.com/2011/07/14/2115.html" >2011/11/03</a>, <a href="http://qwerwqre"  rel="external nofollow"  class="url" >ewrqwer</a> writes: qwerqwerqwerqrew</li></ul><hr/><h2>Related posts:</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2008/08/15/274.html"  rel="bookmark"  title="Permanent Link: PHP 源代码分析 V0.0.2" >PHP 源代码分析 V0.0.2</a></li><li><a href="http://www.laruence.com/2008/07/16/225.html"  rel="bookmark"  title="Permanent Link: Zend Engine幻想" >Zend Engine幻想</a></li><li><a href="http://www.laruence.com/2010/06/21/1608.html"  rel="bookmark"  title="Permanent Link: PHP调试技术手册发布(1.0.0 pdf)" >PHP调试技术手册发布(1.0.0 pdf)</a></li><li><a href="http://www.laruence.com/2011/11/18/2305.html"  rel="bookmark"  title="Permanent Link: GBK编码PHP脚本导致语法错误(Zend Multibyte)" >GBK编码PHP脚本导致语法错误(Zend Multibyte)</a></li><li><a href="http://www.laruence.com/2011/10/10/2229.html"  rel="bookmark"  title="Permanent Link: 函数类型提示(Callable typehint)" >函数类型提示(Callable typehint)</a></li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/10/10/2204.html"  title="JsonSerializable接口" >JsonSerializable接口</a></li><li><a href="http://www.laruence.com/2011/12/06/2381.html"  title="更简单的重现PHP Core的调用栈" >更简单的重现PHP Core的调用栈</a></li><li><a href="http://www.laruence.com/2011/09/23/2171.html"  title="我对PHP5.4的一个改进" >我对PHP5.4的一个改进</a></li><li><a href="http://www.laruence.com/2011/07/13/2110.html"  title="PHP RFC: 让PHP的foreach支持list" >PHP RFC: 让PHP的foreach支持list</a></li><li><a href="http://www.laruence.com/2011/02/13/1870.html"  title="加速PHP的ECHO" >加速PHP的ECHO</a></li><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/02/2515.html"  title="我们什么时候应该使用异常?" >我们什么时候应该使用异常?</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li><li><a href="http://www.laruence.com/2012/01/11/2482.html"  title="PHP的历史" >PHP的历史</a></li><li><a href="http://www.laruence.com/2012/01/10/2469.html"  title="如何设置一个严格30分钟过期的Session" >如何设置一个严格30分钟过期的Session</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/07/14/2115.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>PHP5.4的新特性</title>
		<link>http://www.laruence.com/2011/07/02/2097.html</link>
		<comments>http://www.laruence.com/2011/07/02/2097.html#comments</comments>
		<pubDate>Sat, 02 Jul 2011 13:47:44 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[arraydereferencing]]></category>
		<category><![CDATA[Dtract]]></category>
		<category><![CDATA[php5.4]]></category>
		<category><![CDATA[traits]]></category>
		<category><![CDATA[Webserver SAPI]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2097</guid>
		<description><![CDATA[  PHP5.3刚出来不久, PHP6孕育中的同时, PHP5.4又放出了第一个alpha版本.

     5.4主要包括以下特性:
<coolcode lang="bash" linenum="off">
Added: Traits language construct
Added: Array dereferencing support
Added: DTrace support
Improved: Improved Zend Engine memory usage and performance
Moved: ext/sqlite moved to pecl (sqlite3 support is still built-in)

Removed: break/continue $var syntax
Removed: register_globals, allow_call_time_pass_reference, and register_long_arrays ini options
Removed: session_is_regisitered(), session_registered(), and session_unregister()
</coolcode>

     我们重点关注下新增的这三点...]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/07/02/2097.html"  title="Permanet Link to PHP5.4的新特性" >http://www.laruence.com/2011/07/02/2097.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
     PHP5.3刚出来不久, PHP6孕育中的同时, PHP5.4又放出了第一个alpha版本.</p>
<p>     5.4主要包括以下特性:</p>
<pre name="code"  class="sh_bash"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
Added: Traits language construct
Added: Array dereferencing support
Added: DTrace support
Improved: Improved Zend Engine memory usage and performance
Moved: ext/sqlite moved to pecl (sqlite3 support is still built-in)

Removed: break/continue $var syntax
Removed: register_globals, allow_call_time_pass_reference, and register_long_arrays ini options
Removed: session_is_regisitered(), session_registered(), and session_unregister()
</pre>
<p>     我们重点关注下新增的这三点:</p>
<h3>Traits language construct</h3>
<p>      Traits不是什么新概念了, c++, java都有类似的东西, 只不过这次PHP也引入了进来.</p>
<p>      Traits是一种轻量级的方法复用(相对继承来说).为什么这么说呢?  这就好比, 如果你提供一个基类供用户去继承使用, 那么不可避免的你就需要考虑如何能让用户继承后可用, 如何避免用户改写了某些关键属性, 覆盖了某些关键方法而造成出错. 这个时候你就要考虑改用public还是private, 或者protected, 你还要考虑, 那个方法应该申明为FINAL..</p>
<p>      而如果使用Traits, 那么你就不需要担心这些问题,  它是一种组合方式,  你提供的素材, 无论在任何地方都是自我一个整体. </p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
 &lt;?php
 trait SayWorld {
   public function sayHello() {
     echo 'Hello World!';
   }
 }

 class MyHelloWorld extends Base {
   use SayWorld;
 }

 $o = new MyHelloWorld();
 $o-&gt;sayHello(); // Hello World
</pre>
<p>     Trait和继承以及当前类的同名函数之间的冲突, 有一套固定的解决方案, 也就是当前类的方法覆盖Trait的同名方法, 而Trait中的方法, 覆盖基类的同名方法. 比如:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
 &lt;?php
 class Base {
   public function sayHello() {
     echo 'Hello ';
   }
 }

 trait SayWorld {
   public function sayHello() {
     parent::sayHello();
     echo 'World!';
   }
 }

 class MyHelloWorld extends Base {
   use SayWorld;
 }

 $o = new MyHelloWorld();
 $o-&gt;sayHello(); // echos Hello World
</pre>
<p>      更多关于Traits的信息, 请参考: <a href="https://wiki.php.net/rfc/traits" >Traits for PHP RFC</a></p>
<h3>Array dereferencing support</h3>
<p>     这个可是个好东西,  有了Array dereferencing, 以前的这种写法就再也不必要了:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
    list($name,) = explode(&quot;,&quot;, &quot;Laruence, male&quot;);
?&gt;
</pre>
<p>    取而代之的是:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
  $name = explode(&quot;,&quot;, &quot;Laruence,male&quot;)[0];
</pre>
<p>     另外, 据Cataphrac介绍,  Array derefencing也可以出现再赋值语句的左值中, 也就是理论上你可以这么写:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
explode(&quot;,&quot;, &quot;Laruence,male&quot;)[3] = &quot;phper&quot;;
</pre>
<p>     但也许有朋友会问这个有什么意义么? 呵呵, 当时我也对Cataphrac提出了这样的疑问, 不过后来了解到, 还是有一些场景可以用到的, 比如你先需要调用一个函数做初步处理,然后对处理结果进行调整:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
&lt;?php
function &amp;ref(&amp;$arr) {
    return $arr;
}

$arr = array(1,2,3);
ref($arr)[4] = 4;

var_dump($arr);
?&gt;
</pre>
<h3>DTrace support</h3>
<p>DTrace是一个性能分析工具, 可以跟踪出函数调用点,返回点等数据, 对于这个我也不是很了解, 感兴趣的同学可以参看<a href="http://blog.experimentalworks.net/2010/04/php-5-3-99-dev-and-dtrace-part-i/" >PHP 5.3.99-DEV AND DTRACE PART I</a></p>
<h3>Webserver SAPI</h3>
<p> 最后,  PHP5.4还新增了一个SAPI, 这个SAPI将支持直接把PHP当做Websever使用:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
$ php -S localhost:8000 test.php
//output:
PHP Development Server is listening on localhost:8000 in foo/ ... Press Ctrl-C to quit.
</pre>
<p>  这个特性真的很让我兴奋, 因为在差不多半个月以前, 我就和我的几个同事探讨过, 是否可以做一个类似东西, 来减少Webserver这一层. </p>
<p>  不过, 和philip沟通得知, 这个新的SAPI, 错过了alpha1版本,  应该会在下个测试版, 和最终版中放出来, 也不支持直接patch到php5.4以前的版本(这个比较悲剧, 如果要用, 看来只能自己折腾了). 有关PHP Webserver SAPI的更多信息, 可以参看:<a href="http://docs.php.net/manual/en/features.commandline.webserver.php" >webserver sapi</a><br/>
   <script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_bash.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script></p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/07/02/2097.html" >2011/07/02</a>, <a href="http://www.shaukei.com"  rel="external nofollow"  class="url" >syber</a> writes: session移除了好多，对以前程序是不是不兼容了（有使用到session_registered()的地方）？

webserver sapi是个好消息啊！新特性可以在以后的项目中尝试。</li><li><a href="http://www.laruence.com/2011/07/02/2097.html" >2011/07/02</a>, jaceju writes: 這版似乎沒有把 array 簡寫語法 (也就是以方括號來初始化陣列) 放進去？</li><li><a href="http://www.laruence.com/2011/07/02/2097.html" >2011/07/03</a>, <a href="http://tonyseek.tumblr.com/"  rel="external nofollow"  class="url" >TonySeek</a> writes: Traits language construct 真是让人激动的特性，和 ruby 的 yield block 很像～</li><li><a href="http://www.laruence.com/2011/07/02/2097.html" >2011/07/04</a>, string lau writes: trait MemcachedPolicy {
   void setCache($name, $value)
   { ... }
}

trait MySqlCachePolicy {
   void setCache($name, $value)
   { ... }
}

trait Singleton {
   static $instance = array();
   public static function getInstance() {
       !isset($instance[static]) &amp;&amp; 
        $instance[static] = new static
   }
   return $instance[static]
}
class CacheService {
   use $this-&gt;config-&gt;cachePolicy;
   use Singleton;
}

new CacheService()-&gt;setCache($name, $value);

CacheService::getInstance()-&gt;setCache($name, $value);

期待5.4正式版能支持这些。。</li><li><a href="http://www.laruence.com/2011/07/02/2097.html" >2011/07/07</a>, C writes: 不喜欢Traits
webserver sapi是个好东西, 可以配合HMTL中的WebSocket</li><li><a href="http://www.laruence.com/2011/07/02/2097.html" >2011/07/08</a>, <a href="http://www.weloving.com"  rel="external nofollow"  class="url" >KnightE</a> writes: traits运用的好可以让很多模式实现得更加优雅、轻量，当然用的不好也会破坏很多OO的封装。好与坏本身和traits无关。</li><li><a href="http://www.laruence.com/2011/07/02/2097.html" >2011/08/08</a>, <a href="http://blog.thinkinlamp.com/?p=767"  rel="external nofollow"  class="url" >Thinking In LAMP Blog &raquo; Blog Archive &raquo; PHP每月通讯（2011年8月）</a> writes: [...] http://www.laruence.com/2011/07/02/2097.html 　　PHP5.4的新特性 [...]</li><li><a href="http://www.laruence.com/2011/07/02/2097.html" >2011/11/01</a>, gan writes: 非常好，期待正式版发布</li></ul><hr/><h2>Related posts:</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/03/29/1949.html"  rel="bookmark"  title="Permanent Link: 深入理解PHP原理之Session Gc的一个小概率Notice" >深入理解PHP原理之Session Gc的一个小概率Notice</a></li><li><a href="http://www.laruence.com/2011/12/30/2440.html"  rel="bookmark"  title="Permanent Link: PHP5.2.*防止Hash冲突拒绝服务攻击的Patch" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch</a></li><li><a href="http://www.laruence.com/2008/09/20/523.html"  rel="bookmark"  title="Permanent Link: PHP5.3 α2初体验" >PHP5.3 α2初体验</a></li><li><a href="http://www.laruence.com/2011/10/10/2232.html"  rel="bookmark"  title="Permanent Link: 二进制直接量(binary number format)" >二进制直接量(binary number format)</a></li><li><a href="http://www.laruence.com/2011/12/19/2409.html"  rel="bookmark"  title="Permanent Link: 之前提到的PHP5.4一个注意点的update" >之前提到的PHP5.4一个注意点的update</a></li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/10/10/2204.html"  title="JsonSerializable接口" >JsonSerializable接口</a></li><li><a href="http://www.laruence.com/2011/07/14/2115.html"  title="Zend引擎的优化" >Zend引擎的优化</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/07/02/2097.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Yaf已提交到PECL</title>
		<link>http://www.laruence.com/2011/06/26/2083.html</link>
		<comments>http://www.laruence.com/2011/06/26/2083.html#comments</comments>
		<pubDate>Sat, 25 Jun 2011 19:39:02 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[pecl]]></category>
		<category><![CDATA[php framework]]></category>
		<category><![CDATA[Yaf]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2083</guid>
		<description><![CDATA[  是个值得Yaf纪念的日子..

   <a href="http://pecl.php.net/package/yaf">http://pecl.php.net/package/yaf</a>]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/06/26/2083.html"  title="Permanet Link to Yaf已提交到PECL" >http://www.laruence.com/2011/06/26/2083.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
    是个值得Yaf纪念的日子..</p>
<p>    <a href="http://pecl.php.net/package/yaf" >http://pecl.php.net/package/yaf</a></p>
<p>    btw: 终于有了at php.net马甲了, 呵呵</p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/26</a>, <a href="http://www.cnxct.com"  rel="external nofollow"  class="url" >cfc4n</a> writes: 只有在PECL上贡献项目的人才给 at php.net的马甲？

提交BUG不给吗？</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/26</a>, <a href="http://blog.logx.org"  rel="external nofollow"  class="url" >fcten</a> writes: 我也想要一个 at php.net的马甲 &gt;.&lt;</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/26</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @cfc4n @fcten
三种途径, 1. 开发PHP(PHP Core developer) 2. 开发PECL  3. 翻译PHP手册文档</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/26</a>, yufeng writes: 哗，哥V5啊，是值得纪念，前10的回复会有饭请么，吼吼。</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/26</a>, <a href="http://www.fising.cn"  rel="external nofollow"  class="url" >Fising</a> writes: 膜拜大神。Yaf官网地址是？</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/26</a>, <a href="http://mr.mayday.net.cn"  rel="external nofollow"  class="url" >王道中强流</a> writes: 哇牛XX</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/26</a>, pytonic writes: con~</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/27</a>, venkman writes: 希望能早日用于生产环境啊</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/28</a>, clover writes: 我下载了php-yaf-doc-2.0.zip,用什么软件编译成chm或者其他格式的电子书?????</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/28</a>, kelezyb writes: 能提供一个Win下面的Dll下载么.有利于这个框架的推广啊.感觉这个框架需要做的事情还有很多.</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/28</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @kelezyb 在googlecode上已有</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/06/30</a>, 杜壮壮 writes: 太棒了
Maintainers Xinchen Hui </li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/07/10</a>, seedvirus writes: 鸟哥，感谢你的无私分享</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/07/15</a>, qai41 writes: 恭喜啊, 挺不错的东西</li><li><a href="http://www.laruence.com/2011/06/26/2083.html" >2011/09/02</a>, <a href="http://juan.im"  rel="external nofollow"  class="url" >Juan Felipe Alvarez Saldarriaga</a> writes: Hey!, pretty cool and interesting stuff, I'm a great fan of zend framework, could you provide some speed benchmark? and maybe, just maybe, write the docs in english :P, thanks :).</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/12/02/2333.html"  title="Yaf 2.1性能测试(Yaf 2.1 Benchmark)" >Yaf 2.1性能测试(Yaf 2.1 Benchmark)</a></li><li><a href="http://www.laruence.com/2011/11/05/2262.html"  title="Yaf的性能对比测试" >Yaf的性能对比测试</a></li><li><a href="http://www.laruence.com/2011/08/04/2131.html"  title="Plua进入Pecl" >Plua进入Pecl</a></li><li><a href="http://www.laruence.com/2011/06/28/2088.html"  title="在Windows下编译Yaf" >在Windows下编译Yaf</a></li><li><a href="http://www.laruence.com/2011/05/31/2025.html"  title="在中国PHP技术高峰论坛(2011)上演讲的PPT" >在中国PHP技术高峰论坛(2011)上演讲的PPT</a></li><li><a href="http://www.laruence.com/2011/05/12/2009.html"  title="Yaf-A PHP Framework Extension" >Yaf-A PHP Framework Extension</a></li><li><a href="http://www.laruence.com/2010/10/12/1763.html"  title="PHP的命名空间的实现" >PHP的命名空间的实现</a></li><li><a href="http://www.laruence.com/2010/09/04/1736.html"  title="Yaf-一个PHP扩展实现的PHP框架" >Yaf-一个PHP扩展实现的PHP框架</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/06/26/2083.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>在中国PHP技术高峰论坛(2011)上演讲的PPT</title>
		<link>http://www.laruence.com/2011/05/31/2025.html</link>
		<comments>http://www.laruence.com/2011/05/31/2025.html#comments</comments>
		<pubDate>Tue, 31 May 2011 08:11:12 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[2011PHP技术峰会]]></category>
		<category><![CDATA[ap]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP在百度的应用]]></category>
		<category><![CDATA[Yaf]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2025</guid>
		<description><![CDATA[    本来觉得PPT里没什么东西, 犯不着放出来, 不是内容不丰富哈, 主要都是现场讲的内容.
    
    不过, 既然有人要, 那就放到blog吧, 也当做留个念想.


    总体来说,  这次峰会上,  我介绍了Ap(一个PHP扩展编写的PHP框架,  感兴趣的朋友可以看:<a href="http://www.laruence.com/2011/05/12/2009.html">Yaf-A PHP Framework Extension</a>)在百度的应用.]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/05/31/2025.html"  title="Permanet Link to 在中国PHP技术高峰论坛(2011)上演讲的PPT" >http://www.laruence.com/2011/05/31/2025.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
    本来觉得PPT里没什么东西, 犯不着放出来, 不是内容不丰富哈, 主要都是现场讲的内容.</p>
<p>    不过, 既然有人要, 那就放到blog吧, 也当做留个念想.</p>
<div style="width:425px"  id="__ss_8158352" > <strong style="display:block;margin:12px 0 4px" ><a href="http://www.slideshare.net/laruence/china-php-technology-summit-2011-ppt"  title="China PHP Technology Summit 2011 ppt" >China PHP Technology Summit 2011 ppt</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/8158352"  width="425"  height="355"  frameborder="0"  marginwidth="0"  marginheight="0"  scrolling="no" ></iframe>
<div style="padding:5px 0 12px" > View more <a href="http://www.slideshare.net/" >presentations</a> from <a href="http://www.slideshare.net/laruence" >Laruence Hui</a> </div>
</p></div>
<p>    总体来说,  这次峰会上,  我介绍了Ap(一个PHP扩展编写的PHP框架,  感兴趣的朋友可以看:<a href="http://www.laruence.com/2011/05/12/2009.html" >Yaf-A PHP Framework Extension</a>)在百度的应用.</p>
<p>   以及在这个过程中, 我们做的探索..</p>
<p>   最后, 贴几张当时的照片, 留个纪念吧(在此,感谢下拍照,并且把照片给我的同学们):<br/>
   
<a href="http://www.laruence.com/2011/05/31/2025.html/1105121054e7b096a9aa9263da"  title="1105121054e7b096a9aa9263da" ><img width="150"  height="150"  src="http://laruence-wordpress.stor.sinaapp.com/uploads/1105121054e7b096a9aa9263da-150x150.jpg"  class="attachment-thumbnail"  alt="1105121054e7b096a9aa9263da"  title="1105121054e7b096a9aa9263da" /></a>
<a href="http://www.laruence.com/2011/05/31/2025.html/11051210546316404510d1f61b"  title="11051210546316404510d1f61b" ><img width="150"  height="150"  src="http://laruence-wordpress.stor.sinaapp.com/uploads/11051210546316404510d1f61b-150x150.jpg"  class="attachment-thumbnail"  alt="11051210546316404510d1f61b"  title="11051210546316404510d1f61b" /></a>
<a href="http://www.laruence.com/2011/05/31/2025.html/11051210545af3cdab4319da3b"  title="11051210545af3cdab4319da3b" ><img width="150"  height="150"  src="http://laruence-wordpress.stor.sinaapp.com/uploads/11051210545af3cdab4319da3b-150x150.jpg"  class="attachment-thumbnail"  alt="11051210545af3cdab4319da3b"  title="11051210545af3cdab4319da3b" /></a>
<a href="http://www.laruence.com/2011/05/31/2025.html/11051210546ca70c4423c0931e"  title="11051210546ca70c4423c0931e" ><img width="150"  height="150"  src="http://laruence-wordpress.stor.sinaapp.com/uploads/11051210546ca70c4423c0931e-150x150.jpg"  class="attachment-thumbnail"  alt="11051210546ca70c4423c0931e"  title="11051210546ca70c4423c0931e" /></a>
<a href="http://www.laruence.com/2011/05/31/2025.html/11051210549219f33db67c719e"  title="11051210549219f33db67c719e" ><img width="150"  height="150"  src="http://laruence-wordpress.stor.sinaapp.com/uploads/11051210549219f33db67c719e-150x150.jpg"  class="attachment-thumbnail"  alt="11051210549219f33db67c719e"  title="11051210549219f33db67c719e" /></a>
<a href="http://www.laruence.com/2011/05/31/2025.html/1105121054f627dda5aaf8e83b"  title="1105121054f627dda5aaf8e83b" ><img width="150"  height="150"  src="http://laruence-wordpress.stor.sinaapp.com/uploads/1105121054f627dda5aaf8e83b-150x150.jpg"  class="attachment-thumbnail"  alt="1105121054f627dda5aaf8e83b"  title="1105121054f627dda5aaf8e83b" /></a>
</p>
<p>    最后,  老有人问, 为啥有人叫我&#8221;鸟哥&#8221;, 这个和&#8221;鸟哥私房菜&#8221;的鸟哥,真的是没一点关系, 他是台湾的Linux大牛&#8230;</p>
<p>    我呢,, 只是因为我的IM的昵称叫做&#8221;雪候鸟&#8221;, 又因为在公司属于比较老的那种, 所以公司的同事们就会这么叫我了&#8230;</p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/05/31/2025.html" >2011/05/31</a>, xinqiyang writes: 看到鸟哥介绍AP框架了，竟然是沙发</li><li><a href="http://www.laruence.com/2011/05/31/2025.html" >2011/06/01</a>, <a href="http://www.rabbitlog.net"  rel="external nofollow"  class="url" >ryan</a> writes: PPT看不了了~~~~</li><li><a href="http://www.laruence.com/2011/05/31/2025.html" >2011/06/08</a>, Nathan Qu writes: PPT的第15页应该是有个笔误：
time() - $_SERVER[REQUEST_TIME]
会报Notice并产生把常量REQUEST_TIME当成字符串使用的开销。
对新手可能是个误导，还是改一下PPT把引号加上吧。</li><li><a href="http://www.laruence.com/2011/05/31/2025.html" >2011/06/08</a>, Nathan Qu writes: 不好意思手斗点错了~
上面的那条评论应该是针对这篇文章的 http://www.laruence.com/2011/05/31/2018.html</li><li><a href="http://www.laruence.com/2011/05/31/2025.html" >2011/06/08</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @Nathan Qu 谢谢指出, :)</li><li><a href="http://www.laruence.com/2011/05/31/2025.html" >2011/06/09</a>, 王洛堇 writes: PPT12页开始就都看不懂了……
照片不错，鸟哥在紧张吗？</li><li><a href="http://www.laruence.com/2011/05/31/2025.html" >2011/06/09</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @王洛堇 有点小紧张...</li><li><a href="http://www.laruence.com/2011/05/31/2025.html" >2011/07/04</a>, <a href="http://ncist.rayyn.net"  rel="external nofollow"  class="url" >guitar</a> writes: 原来是这个鸟哥啊...膜拜</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2010/10/12/1763.html"  title="PHP的命名空间的实现" >PHP的命名空间的实现</a></li><li><a href="http://www.laruence.com/2010/09/04/1736.html"  title="Yaf-一个PHP扩展实现的PHP框架" >Yaf-一个PHP扩展实现的PHP框架</a></li><li><a href="http://www.laruence.com/2012/02/08/2528.html"  title="PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)" >PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830)</a></li><li><a href="http://www.laruence.com/2012/02/02/2515.html"  title="我们什么时候应该使用异常?" >我们什么时候应该使用异常?</a></li><li><a href="http://www.laruence.com/2012/02/01/2503.html"  title="使用exit(-1)为什么得到255退出码?" >使用exit(-1)为什么得到255退出码?</a></li><li><a href="http://www.laruence.com/2012/01/11/2482.html"  title="PHP的历史" >PHP的历史</a></li><li><a href="http://www.laruence.com/2012/01/10/2469.html"  title="如何设置一个严格30分钟过期的Session" >如何设置一个严格30分钟过期的Session</a></li><li><a href="http://www.laruence.com/2012/01/07/2453.html"  title="2012年1月全球www网站技术报告" >2012年1月全球www网站技术报告</a></li><li><a href="http://www.laruence.com/2011/12/30/2440.html"  title="PHP5.2.*防止Hash冲突拒绝服务攻击的Patch" >PHP5.2.*防止Hash冲突拒绝服务攻击的Patch</a></li><li><a href="http://www.laruence.com/2011/12/30/2435.html"  title="PHP数组的Hash冲突实例" >PHP数组的Hash冲突实例</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/05/31/2025.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>PHP Performance Optimization</title>
		<link>http://www.laruence.com/2011/05/31/2018.html</link>
		<comments>http://www.laruence.com/2011/05/31/2018.html#comments</comments>
		<pubDate>Tue, 31 May 2011 07:51:54 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[LAMP优化]]></category>
		<category><![CDATA[PHP Performance]]></category>
		<category><![CDATA[PHP优化]]></category>
		<category><![CDATA[性能优化]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=2018</guid>
		<description><![CDATA[ 4月的时候, 做了一个关于PHP性能优化的技术交流.

 今天把当时交流的PPT放到slideShare了. 

    顺便谈一下对PHP性能优化的一些看法.]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2011/05/31/2018.html"  title="Permanet Link to PHP Performance Optimization" >http://www.laruence.com/2011/05/31/2018.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>
    4月的时候, 做了一个关于PHP性能优化的技术交流.</p>
<p>    今天把当时交流的PPT放到slideShare了. </p>
<p>    顺便谈一下对PHP性能优化的一些看法.</p>
<p>   1.  优化建议目的不是为了优化, 而是为了防微杜渐..</p>
<p>   在PPT中罗列的编码时候的优化建议, 不是为了让大家在出现性能问题的时候, 以这些作为准则去对代码进行优化.   而是希望能在大家最初写代码的时候, 就有一个心理的认知, 应该怎么写会更好.</p>
<p>    2. 优化的建议不是准则</p>
<p>    当我把PPT分享给公司的同事的时候, 会有人质疑, 魔术方法都不让用?  </p>
<p>    优化的建议, 是建议, 是防止大家滥用, 肆无忌惮的用.  如果你能在写代码的时候, 能意识到, 什么慢, 什么快, 从而避免一些没有必要的对魔术方法的调用, 那就是这个优化建议所追求的效果了</p>
<p>    比如, 我在<a href="http://www.laruence.com/2011/05/12/2009.html" >Yaf</a>中, 为视图引擎定义了魔术方法__set,  于是就有些朋友这么来用:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
$this-&gt;getView()-&gt;user =  &quot;laruence&quot;;
$this-&gt;getView()-&gt;age  = 28;
$this-&gt;_view-&gt;desc      = &quot;PHP engineer&quot;;
</pre>
<p>    如果是写C, 那么没有问题, 但是在PHP中, 每一个set都是一个函数调用, 所以看过了性能优化建议, 大家能意识到, 其实这个完全可以通过:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
$this-&gt;getView()-&gt;assign(array(
      &quot;user&quot; =&gt; &quot;laruence&quot;,
      &quot;age&quot;  =&gt; 28,
      &quot;desc&quot; =&gt; &quot;PHP engineer&quot;,
));;
</pre>
<p>   来替代, 那就是优化建议所希望达到的效果.</p>
<p>   3. 优化建议不是通用的,  是和语言相关的</p>
<p>   有很多PHPer以前是写C的,  也可能是写Java的,  虽说语言只是工具,  但是要想用的好, 你还是应该了解工具的特点, 为不同的工具做不同的优化策略.</p>
<p>   比如, 对于C来说, 它有一个很强大的编译&#8221;优化&#8221;器, 可以为你做很多优化, 而PHP是解释型脚本语言,  它只会重视的执行你的代码, 不会做任何优化, 所以, 你写的代码的风格, 直接影响到最终的执行风格.</p>
<p>   还有, 对于C来说, 符号在执行器都会变成地址(绝大部分),  而对于PHP来说, 符号都需要经过查找(Hash Lookup)才能使用,  于是我也看到了类似下面的代码:</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
for ($i=0; i&lt;10;i++) {
   $arr[1][2][3][4][5] = $i;
}
</pre>
<p>  每一次循环, 都会带来6次的Hash Lookup&#8230;..</p>
<p>   4. 要知根究底<br/>
   PHP是一个很高级的语言, 使用它可以很方便, 很简洁的完成一些功能.</p>
<p>   但是, 追根究底, 它也是最终通过c代码, 继而汇编, 机器码去执行的. 也许看似简单的一条PHP语句, 最终可能需要数十条, 上百条的C语言代码来完成.</p>
<p>   而我们, 只有理解到这个过程, 才能真正做到, 在高级语言层面, 做出对底层有正面影响的优化.</p>
<div style="width:425px"  id="__ss_8158110" > <strong style="display:block;margin:12px 0 4px" ><a href="http://www.slideshare.net/laruence/php-performance-8158110"  title="Php performance" >Php performance</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/8158110"  width="425"  height="355"  frameborder="0"  marginwidth="0"  marginheight="0"  scrolling="no" ></iframe>
<div style="padding:5px 0 12px" > View more <a href="http://www.slideshare.net/" >presentations</a> from <a href="http://www.slideshare.net/laruence" >Laruence Hui</a> </div>
</p></div>
<p>    最后, 如果slideshare被&#8221;挡&#8221;了,, 点击这里下载看吧: <a href="http://laruence-wordpress.stor.sinaapp.com/uploads/phpperformance-110531022350-phpapp02.ppt" >PHP Performance PPT</a><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script></p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/05/31/2018.html" >2011/06/01</a>, <a href="http://liguangming.com"  rel="external nofollow"  class="url" >cute</a> writes: 那个strlen($str)==5 isset($str{5})应该是isset($str{4})吧</li><li><a href="http://www.laruence.com/2011/05/31/2018.html" >2011/06/01</a>, <a href="http://liguangming.com"  rel="external nofollow"  class="url" >cute</a> writes: preg_match("/[a8f9]/", "sometext")
strpbrk("a8f9", "sometext")
应该为strpbrk("sometext", "a8f9")</li><li><a href="http://www.laruence.com/2011/05/31/2018.html" >2011/06/01</a>, <a href="http://www.laruence.com"  rel="external nofollow"  class="url" >雪候鸟</a> writes: @cute 多谢指正, :), 已经修改~</li><li><a href="http://www.laruence.com/2011/05/31/2018.html" >2011/06/02</a>, <a href="http://www.iirr.info/blog/"  rel="external nofollow"  class="url" >HorseLuke</a> writes: Prefer Use Static Methods这段看不明白，用静态的效率比动态快3倍？
还有Do Work for PHP中的“Use instant instead of variable”下面的代码，也不明白。这种写法的优化在哪里？</li></ul><hr/><h2>Related posts:</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/11/04/2258.html"  rel="bookmark"  title="Permanent Link: 三元式(ternary)性能优化" >三元式(ternary)性能优化</a></li><li><a href="http://www.laruence.com/2011/11/05/2262.html"  rel="bookmark"  title="Permanent Link: Yaf的性能对比测试" >Yaf的性能对比测试</a></li><li><a href="http://www.laruence.com/2011/07/02/2097.html"  rel="bookmark"  title="Permanent Link: PHP5.4的新特性" >PHP5.4的新特性</a></li><li><a href="http://www.laruence.com/2011/12/02/2333.html"  rel="bookmark"  title="Permanent Link: Yaf 2.1性能测试(Yaf 2.1 Benchmark)" >Yaf 2.1性能测试(Yaf 2.1 Benchmark)</a></li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Random Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2011/05/05/2002.html"  title="Apache Access Log中的Options的含义" >Apache Access Log中的Options的含义</a></li><li><a href="http://www.laruence.com/2008/09/23/539.html"  title="使用PHP Embed SAPI实现Opcodes查看器" >使用PHP Embed SAPI实现Opcodes查看器</a></li><li><a href="http://www.laruence.com/2008/11/11/606.html"  title="图解aclocal、autoconf、automake、autoheader、configure" >图解aclocal、autoconf、automake、autoheader、configure</a></li><li><a href="http://www.laruence.com/2009/05/14/803.html"  title="浏览器的结构" >浏览器的结构</a></li><li><a href="http://www.laruence.com/2010/11/02/1789.html"  title="[转载]技术文化和惨淡命运 —— 怀念中国雅虎" >[转载]技术文化和惨淡命运 —— 怀念中国雅虎</a></li><li><a href="http://www.laruence.com/2010/05/28/1565.html"  title="PHP错误抑制符(@)导致引用传参失败的Bug" >PHP错误抑制符(@)导致引用传参失败的Bug</a></li><li><a href="http://www.laruence.com/2010/04/15/1414.html"  title="深入理解ob_flush和flush的区别" >深入理解ob_flush和flush的区别</a></li><li><a href="http://www.laruence.com/2011/11/09/2277.html"  title="PHP原理之内存管理中难懂的几个点" >PHP原理之内存管理中难懂的几个点</a></li><li><a href="http://www.laruence.com/2009/12/26/1198.html"  title="深入理解PHP原理之变量生命期(一)" >深入理解PHP原理之变量生命期(一)</a></li><li><a href="http://www.laruence.com/2009/08/22/1059.html"  title="字符编码详解(基础)" >字符编码详解(基础)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2011/05/31/2018.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

