<div class="title_bot"><script>ec(2);</script></div> <br><br><span style="color: rgb(0, 0, 0);">PHP </span><span style="color: rgb(0, 0, 0);">5.3</span><span style="color: rgb(0, 0, 0);"> 介绍<br>PHP </span><span style="color: rgb(0, 0, 0);">2008</span><span style="color: rgb(0, 0, 0);"> 魁北克</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> Ilia Alshanetsky<br><br><br> </span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);"> 新版本的特性<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 兼职老版本下的代码<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 重点主要放在现有的功能的改进<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 更少的bug<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 更快的发布周期<br><br><br></span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);"> 命名空间(Namespaces)<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> PHP5</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">3最大的新功能<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 完全支持名字空间特征<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 大部分的功能的执行在编译时<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 简化命名惯例<br><br></span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">) 更清晰的代码<br><br> 不使用 Namespaces<br> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> MY_wrapper() {}<br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> MY_DB {}<br> </span><span style="color: rgb(0, 128, 128);">define</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">''</span><span style="color: rgb(0, 0, 0);">MY_COMM_STR</span><span style="color: rgb(0, 0, 0);">''</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">''''</span><span style="color: rgb(0, 0, 0);">);<br><br> <br> MY_wrapper();<br> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MY_DB();<br> MY_COMM_STR;<br><br></span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">) 使用 Namespaces<br> <br> namespace MY;<br> <br> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> wrapper() {}<br> <br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> DB { }<br> <br> </span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> CONN_STR </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">''''</span><span style="color: rgb(0, 0, 0);">;<br> <br> <br> </span><span style="color: rgb(0, 0, 255);">use</span><span style="color: rgb(0, 0, 0);"> MY </span><span style="color: rgb(0, 0, 255);">AS</span><span style="color: rgb(0, 0, 0);"> MY;<br> <br> wrapper();<br> <br> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> DB();<br> <br> CONN_STR;<br> <br><br><br></span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">) 一个文件中多个名字空间<br> <br> namespace LIB;<br> <br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">MYSQL</span><span style="color: rgb(0, 0, 0);"> {}<br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> SQLite {}<br> <br> </span><span style="color: rgb(128, 0, 128);">$b</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> SQLite(;<br> <br> namespace LIB_EXTRA;<br> <br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> MScrypt {}<br> <br> </span><span style="color: rgb(128, 0, 128);">$a</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MScrypt();<br> <br> </span><span style="color: rgb(0, 128, 128);">var_dump</span><span style="color: rgb(0, 0, 0);">(<br> </span><span style="color: rgb(0, 128, 128);">get_class</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(128, 0, 128);">$a</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"><br> </span><span style="color: rgb(0, 128, 128);">get_class</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(128, 0, 128);">$b</span><span style="color: rgb(0, 0, 0);">)<br> };<br> <br> </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> result:<br> // string(18) "LIB_EXTRA::MScrypt"<br> // string(11) "LIB::SQLite"</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"><br><br><br><br><br></span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">) 名字空间的层级<br><br> namespace foo;<br> <br> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">strlen</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(128, 0, 128);">$foo</span><span style="color: rgb(0, 0, 0);">) { </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">htmlspecialchars</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(128, 0, 128);">$foo</span><span style="color: rgb(0, 0, 0);">); }<br> <br> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">strlen</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">test</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> test</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 128, 128);">strlen</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">test</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 4</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> namespace</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 128, 128);">strlen</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">test</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> test</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> <br> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> 和 </span><span style="color: rgb(0, 128, 128);">constant</span><span style="color: rgb(0, 0, 0);"> 引用在一个名字空间中首先指向这个名字空间</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> 其次才是一个全局的范围<br><br><br></span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">) 名字空间 </span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);"> 自动引入<br><br><br> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> __autoload(</span><span style="color: rgb(128, 0, 128);">$var</span><span style="color: rgb(0, 0, 0);">) { </span><span style="color: rgb(0, 128, 128);">var_dump</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(128, 0, 128);">$var</span><span style="color: rgb(0, 0, 0);">); } </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> LIB::foo</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">require</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">./ns.php</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br> </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">*<br> <?php <br /> namespace LIB;<br> new foo();<br> ?><br> </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> __autoload() 将处理为和名字空间的类名一起。<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> autoload 仅在 </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> 不在名字空间和全局范围内存在时触发。<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> __autoload() 声明在一个名字空间中将不别调用!<br><br><br><br><br></span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">) 其他的名字空间的语法技巧<br><br> namespace really</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">long</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">pointlessly</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">verbose</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">ns;<br> <br> __NAMESPACE__; </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 当前的名字空间名称</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> <br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> a {}<br> <br> </span><span style="color: rgb(0, 128, 128);">get_class</span><span style="color: rgb(0, 0, 0);">( </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> a() ); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> really::long::pointlessly::verbose::ns::abs</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> <br> </span><span style="color: rgb(0, 0, 255);">use</span><span style="color: rgb(0, 0, 0);"> really</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">long</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">pointlessly</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">verbose</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">ns</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">a </span><span style="color: rgb(0, 0, 255);">AS</span><span style="color: rgb(0, 0, 0);"> b; </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 从一个名字空间引用class</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"><br> <br><br><br></span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);"> 改进的性能<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">md5</span><span style="color: rgb(0, 0, 0);">() 速度提高了大概10</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">15</span><span style="color: rgb(0, 0, 0);">%</span><span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 引擎中更好的堆栈实现<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 常量移到只读内存区<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 改进Exception处理(更简单 </span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);"> 更少的代码)<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 调用 (</span><span style="color: rgb(0, 0, 255);">require</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 255);">include</span><span style="color: rgb(0, 0, 0);">)_once 去掉了使用open(</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">)(linux下的c函数)<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 使用gcc4编译的二进制更小更快<br><br>整体性能提高 </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">15</span><span style="color: rgb(0, 0, 0);">%</span><span style="color: rgb(0, 0, 0);"><br><br><br><br></span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);"> 新的语言特性<br><br><br></span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">) __DIR__<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 引入 __DIR__ magic常量 定位脚本的目录<br><br> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">dirname</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(255, 0, 255);">__FILE__</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> <span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> <br> </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> vs </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br> <br> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> __DIR__; </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> >= 5.3</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"><br><br></span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);">?:</span><span style="color: rgb(0, 0, 0);"> 操作符<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 允许从2个值的or</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">and表达式快速的获取一个非空的值<br> <br> </span><span style="color: rgb(128, 0, 128);">$a</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">?:</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">; </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true;</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$a</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">?:</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">; </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true;</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$a</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">?:</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">; </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 1</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$a</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">?:</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">; </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 2</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$a</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">array</span><span style="color: rgb(0, 0, 0);">() </span><span style="color: rgb(0, 0, 0);">?:</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">array</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> array(1);</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$a</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">strlen</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);">?:</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">strlen</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 1</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> <br><br><br><br></span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">) __callStatic()<br> <br> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 等价于 __call() </span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> 但它是为调用静态方法准备的<br> <br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> helper<br> {<br> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> __callStatic(</span><span style="color: rgb(128, 0, 128);">$name</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$args</span><span style="color: rgb(0, 0, 0);">){<br> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$name</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">''</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">''</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 128, 128);">implode</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">''</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">''</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$args</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">''</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 0);">''</span><span style="color: rgb(0, 0, 0);">;<br> } <br> }<br> <br> helper</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">test(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">foo</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bar</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> test(foo,bar);<br><br><br>// 动态的函数/方法调用有点慢...</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> <br> </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">) 动态的调用静态方法<br> <br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> php 现在允许 动态的调用静态的方法<br> <br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> helper<br> {<br> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> foo(){<br> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">__METHOD__</span><span style="color: rgb(0, 0, 0);">;`<br> } <br> }<br> <br> </span><span style="color: rgb(128, 0, 128);">$a</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">helper</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br> </span><span style="color: rgb(128, 0, 128);">$b</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">foo</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br> <br> </span><span style="color: rgb(128, 0, 128);">$a</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(128, 0, 128);">$b</span><span style="color: rgb(0, 0, 0);">(); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> helper::foo<br><br>// 动态的函数/方法调用有点慢...</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">) 延迟静态绑定<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 静态处理从编译时延迟到执行时<br> <br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> A<br> {<br> </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> whoami(){<br> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">__CLASS__</span><span style="color: rgb(0, 0, 0);">; <br> }<br> <br> </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> identity(){<br> self</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">whoami(); <br> }<br> }<br> <br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> B </span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);"> A<br> {<br> </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> whoami(){<br> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">__CLASS__</span><span style="color: rgb(0, 0, 0);">;<br> }<br> }<br> <br> B</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">identity(); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> A <span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> <br> <br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> A<br> {<br> </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> whoami(){<br> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">__CLASS__</span><span style="color: rgb(0, 0, 0);">; <br> }<br> <br> </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> identity(){<br> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">whoami(); <br> }<br> }<br> <br> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> B </span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);"> A<br> {<br> </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> whoami(){<br> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">__CLASS__</span><span style="color: rgb(0, 0, 0);">;<br> }<br> }<br> <br> B</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">identity(); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> B = 5.3</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> <br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 小心使用操作码缓存,没有向后兼容<br><br><br><br></span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">) MySQLInd<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 特殊的,高速的专门为PHP设计的MySQL调用库接口<br><br></span><span style="color: rgb(0, 0, 0);"><br><br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 更好的性能<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 内存的使用优化<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 内置的驱动(不是适应性的再次扩展)<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> Many future options due to tight integration with PHP<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 目前还没有PDO_MySQL 支持 </span><span style="color: rgb(0, 128, 128);">mysql</span><span style="color: rgb(0, 0, 0);">(i) only </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> now<br><br><br><br><br><br></span><span style="color: rgb(0, 0, 0);">7</span><span style="color: rgb(0, 0, 0);">) INI Magic<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> CGI</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">FastCGI 支持</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">.htaccess</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> 形式的INI控制<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 用户可以自己设定每个目录的INI在php</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">ini中通过[PATH</span><span style="color: rgb(0, 0, 0);">=/</span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">www</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">domain</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com]设定<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 优化错误处理<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 允许用户使用INI变量和常量任何定义的INI文件中<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 其他几个小的优化<br><br><br> 用户自定义的php</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">ini(</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">htaccess) 文件名</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);"> 默认为</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">.user.ini</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br> user_ini</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">filename </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">.user.ini</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br><br><br>禁止这个特性 设置这个选项为空值<br><br><br> 用户自定义php</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">ini 的缓存失效期(</span><span style="color: rgb(0, 128, 128);">time</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">to</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">live) 秒数</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);"> 默认is 300s (5分钟)<br> user_ini</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">cache_ttl </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> 300s<br> <br> [PATH</span><span style="color: rgb(0, 0, 0);">=/</span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">www</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">domain</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com]<br> variables_order </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> GPC<br> safe_mode </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"><br><br> [my varibles]<br> somevar </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">1234</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br> anothervar </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> ${somevar} ; anothervar </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> somevar<br><br> [ini arrays]<br> foo[bar] </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"><br> foo[</span><span style="color: rgb(0, 0, 0);">123</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);"><br> foo[] </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);"><br><br><br><br></span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);">) 扩展的 OpenSSL 函数<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 使用 OpenSSL Digest 函数<br><br> </span><span style="color: rgb(0, 0, 255);">foreach</span><span style="color: rgb(0, 0, 0);"> (openssl_get_md_methods() </span><span style="color: rgb(0, 0, 255);">as</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$d</span><span style="color: rgb(0, 0, 0);">) {</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> MD4, MD5, SHA512... (12 all in all)</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">echo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$d</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> - </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);"> openssl_digest(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">foo</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">md5</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> acbd18db4cc2f85cedef654fccc4a4d8</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> }<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 使用 OpenSSL 加密函数<br><br> </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> BF-CBC, AES-256 CFB1... (54 all in all)</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">foreach</span><span style="color: rgb(0, 0, 0);">(openssl_get_cipher_methods() </span><span style="color: rgb(0, 0, 255);">as</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$v</span><span style="color: rgb(0, 0, 0);">) {<br> </span><span style="color: rgb(128, 0, 128);">$val</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> openssl_encrypt(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">value</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$v</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">secret</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br> openssl_decrypt(</span><span style="color: rgb(128, 0, 128);">$val</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$v</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">secret</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> value</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> }<br><br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 扩展的 openssl_pkey_new() 和 openssl_pkey_get_details()<br>函数 允许访问 内部的 DSA</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> RSA 和 DH 密匙</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);"><br><br><br>其目标在PHP中实现一个简单的OpenId<br><br><br> </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);">) SPL(Standard PHP Library) 优化<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 优化嵌套的目录迭代次数由文件系统迭代<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 引入 GlobIterator<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 各种各样的数据结构类</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 0, 0);"> 双链表</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> 堆栈</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> 队列</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> 堆</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> 小型堆</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> 大型堆</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> 优先级队列<br> <br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 其他的很绕口的一些特征<br><br><br></span><span style="color: rgb(0, 0, 0);">10</span><span style="color: rgb(0, 0, 0);">) 时间处理进行扩展了和添加<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 可控制的 </span><span style="color: rgb(0, 128, 128);">strtotime</span><span style="color: rgb(0, 0, 0);">() 由 date_create_from_format()实现<br> <br> </span><span style="color: rgb(128, 0, 128);">$date</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">strtotime</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">08-01-07 00:00:00</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br> </span><span style="color: rgb(0, 128, 128);">var_dump</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 128, 128);">date</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Y-m-d</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$date</span><span style="color: rgb(0, 0, 0);">)); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> string(10) "2008-01-07"</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$date</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> date_create_from_format(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">m-d-y</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">08-01-07</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br> </span><span style="color: rgb(0, 128, 128);">var_dump</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(128, 0, 128);">$date</span><span style="color: rgb(0, 0, 0);">-></span><span style="color: rgb(0, 0, 0);">format(</span><span style="color: rgb(0, 0, 0);">''</span><span style="color: rgb(0, 0, 0);">Y-m-d</span><span style="color: rgb(0, 0, 0);">''</span><span style="color: rgb(0, 0, 0);">)); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> string(10) "2007-08-01"</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 添加了 date_get_last_errors()</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">并且返回时间语法分析的错误和警告<br> </span><span style="color: rgb(0, 0, 255);">array</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">) {<br> [</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">warning_count</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">=></span><span style="color: rgb(0, 0, 0);"> int(</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">)<br> [</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">warnings</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">=></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">array</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">) { }<br> [</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">error_count</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">=></span><span style="color: rgb(0, 0, 0);"> int(</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">)<br> [</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">errors</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">=></span><span style="color: rgb(0, 0, 0);"><br> </span><span style="color: rgb(0, 0, 255);">array</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">) {<br> [</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">=></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">40</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">The separation symbol could not be found</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br> [</span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">=></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">13</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Trailing data</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br> }<br> }<br><br><br> </span><span style="color: rgb(0, 0, 0);">11</span><span style="color: rgb(0, 0, 0);">) getopt() 优化<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 影响 Windows 平台<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 本地的执行不依赖于本地getopt()实现</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);"><br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 跨平台支持长选项 (</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">option)<br> </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> input: --a=foo --b --c</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">var_dump</span><span style="color: rgb(0, 0, 0);">(getopt(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">array</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">b::</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">c</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">)));<br> </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> output: array(3) {<br> ["a"]=><br> string(3) "foo"<br> ["b"]=><br> bool(false)<br> ["c"]=><br> bool(false)<br> } </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br><br><br> </span><span style="color: rgb(0, 0, 0);">12</span><span style="color: rgb(0, 0, 0);">) XSLT Profiling<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 引入 Xslt Profiling 通过 setProfiling()实现<br><br> </span><span style="color: rgb(128, 0, 128);">$xslt</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> xsltprocessor();<br> </span><span style="color: rgb(128, 0, 128);">$xslt</span><span style="color: rgb(0, 0, 0);">-></span><span style="color: rgb(0, 0, 0);">importStylesheet(</span><span style="color: rgb(128, 0, 128);">$xml</span><span style="color: rgb(0, 0, 0);">);<br> </span><span style="color: rgb(128, 0, 128);">$xslt</span><span style="color: rgb(0, 0, 0);">-></span><span style="color: rgb(0, 0, 0);">setProfiling(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/tmp/profile.txt</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br> </span><span style="color: rgb(128, 0, 128);">$xslt</span><span style="color: rgb(0, 0, 0);">-></span><span style="color: rgb(0, 0, 0);">transformToXml(</span><span style="color: rgb(128, 0, 128);">$dom</span><span style="color: rgb(0, 0, 0);">);<br> <br> Resulting In</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 0, 0);"><br> </span><span style="color: rgb(0, 0, 255);">number</span><span style="color: rgb(0, 0, 0);"> match name mode Calls Tot 100us Avg<br> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">date</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">58</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">11</span><span style="color: rgb(0, 0, 0);"><br> Total </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">58</span><span style="color: rgb(0, 0, 0);"><br><br><br> </span><span style="color: rgb(0, 0, 0);">13</span><span style="color: rgb(0, 0, 0);">) E_DEPRECATED 标记<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 怎么样将一个php发行为一个没有错误的模式</span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);"> 废弃<br><br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> E_DEPRECATED用来指定废弃的功能,或许未来的版本中会消除。<br><br><br> </span><span style="color: rgb(0, 0, 0);">14</span><span style="color: rgb(0, 0, 0);">) 垃圾回收器<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 为复杂和长时间运行脚本的执行结束周期释放内存的清理<br> <br> gc_enable(); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 允许垃圾回收</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">var_dump</span><span style="color: rgb(0, 0, 0);">(gc_enabled()); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 128);">var_dump</span><span style="color: rgb(0, 0, 0);">(gc_collect_cycles()); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 某个元素的清理</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> gc_disable(); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 禁止垃圾回收</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"> <br> </span><span style="color: rgb(0, 0, 0);">15</span><span style="color: rgb(0, 0, 0);">) NOWDOC<br></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> 一个 HEREDOC 不再进行转译<br><br> HEREDOC<br> </span><span style="color: rgb(128, 0, 128);">$foo</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);">ONE<br> this is </span><span style="color: rgb(128, 0, 128);">$fubar</span><span style="color: rgb(0, 0, 0);"><br> ONE;<br> </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> string(10) "this is" </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br> <br> NOWDOC<br>&</span></span></span></span>