1、引入 __DIR__ magic常量 定位脚本的目录
echo __DIR__."|".dirname(__FILE__);
2、允许从2个值的or/and表达式快速的获取一个非空的值
echo (1 ?: 0) ."|". ("" ?: 0)."|". var_export(array() ?: array(1), true);
3、类添加__callStatic方法,等价于 __call(),但它是为调用静态方法准备的。下面来看示例:
class xxx{
function __call($func, $args){
echo "function name:".$func;
echo "</br />";
echo "args:".var_export($args, true);
}
static function __callStatic($func, $args){
echo "static function name:".$func;
echo "</br />";
echo "static args:".var_export($args, true);
}
}
$x = new xxx();
$x->testfunc("oo");
echo "</br />";
xxx::teststatic("xx");
4、动态的调用静态的方法
class xx{
static function test(){
echo __METHOD__;
}
}
$c = "xx";
$m = "test";
$c::$m();
5、延迟静态绑定(静态处理从编译时延迟到执行时)
class A{
static function whoami(){
echo __CLASS__;
}
static function say1(){
self::whoami();
}
static function say2(){
static::whoami();
}
}
class B extends A{
static function whoami(){
echo __CLASS__;
}
}
class C extends A{
static function whoami(){
echo __CLASS__;
}
}
B::say1();
C::say2();
6、MySQLInd (高速的专门为PHP设计的MySQL调用库接口)
7、INI Magic
8、扩展的 OpenSSL 函数
9、SPL(Standard PHP Library) 优化
10、时间处理进行扩展了和添加
$date = strtotime("11-05-17 00:00:00");
echo date("Y-m-d", $date)."|";
$date = date_create_from_format("y-m-d", "11-05-17");
echo $date->format("Y-m-d");
11、垃圾回收器(为复杂和长时间运行脚本的执行结束周期释放内存的清理)
gc_enable(); // 允许垃圾回收
var_dump(gc_enabled()); // true
var_dump(gc_collect_cycles()); // 某个元素的清理
gc_disable(); // 禁止垃圾回收
12、NOWDOC(不对HEREDOC进行转译)
$fubar = "xxx";
$xbar = <<<ONE
this is HEREDOC $fubar
ONE;
$abar = <<<'TWO'
this is NOWDOC $fubar
TWO;
echo $xbar."|".$abar;
13、匿名函数体验
$ofun = create_function('$a, $b', 'return $a*$b;'); //不要忘了分号,传统方法
echo $ofun(2, 5);
$nfun = function ($a, $b){
return $a*$b;
};//不要忘了分号,现代方法
echo $nfun(3, 5);
14、闭包体验
$arr = array(1, 2, 3, 5, 6, 7);
$res = array_filter($arr, function($v) { return $v >4; });
var_dump($res);
function countnum(){
$num = 0;
$testt = function() use(&$num){
++$num;
echo $num;
};
return $testt;
}
$t = countnum();
$t();
$t();
15、命名空间
namespace xxx; //第一个namespace需要在所有输出之前
function t(){
return __NAMESPACE__;
}
namespace xxx;
function t(){
return __NAMESPACE__;
}
echo \xx\t()."|";
echo \xxx\t();
分享到:
相关推荐
(积分会自动改,需要的留言)phpemail 适用php5.3版本,目前github上的phpemail对于5.3好像有不少问题。 实例(含代码):https://blog.csdn.net/github_38854224/article/details/91490084
ACS 5.3 license亲测可用
归纳了PHP从5.3到7的新特性。希望帮助到有用的人。
sudo apt-get install php5 php5-common php5-cli php5-dev php5-mysql phpmyadmin php5-pgsql phppgadmin php5-gd php5-mcrypt php5-curl php-pear libapache2-mod-php5 php5-xdebug php5-codesniffer What is much...
5.3 白盒测试白盒测试概述概念又称为结构测试或逻辑驱动测试目的对路径、分支、循环和内部数据结构进行检查测试过程测试覆盖标准特点以内部逻辑为基础设计测试用例考虑
PHP5.3新特性概况,静态延迟绑定,命名空间,支持goto,新增__DIR__······
php5.3X64位支持win2008r2
php5.3 64位WampServer 找了很久才找到
php5.3安装版,win32位,线程安全
PHP 5.3新特性.pdf
最新的版本。可以实现Windows环境下php5.3+apache配置 。
php5.3版本的wampserver,可以兼容win10
memcache用于PHP5.3非线程版本,好些都是单独版本,全版本的不好找喔。
php_imagick-3.1.2-5.3-nts-vc9-x86 适用于php-5.3-nts-vc9-x86
PHP_5.3_与_PHP_5.2_开发区别和新特性
本人资源中还有很多关于php开发的软件 源码 工具 php扩展等等,希望可以帮到你例如 Linux.chm 成就linux高手 php php-5.4.9.tar.gz php-5.3.19.tar.gz jquery1.8.0 chm 中文手册 jquery1.7.1.chm 中文手册 ...
AIX5.3Solaris10新特性培训教材.doc
php在线调试工具,一个php扩展,适用于php5.3以上版本 md5: c89ad0136b75f2e25f0e23f05677bcaa 具体文档介绍见 http://blog.csdn.net/micweaver/article/details/17891163
兼容到php5.3-php7的Smtp类,亲测可用。在网上找了很多在不同版本的PHP上会报错或者不稳定,这个是相对比较好用简单且稳定的。一共有两个版本,可供选择。
php5.3版本的官方开发文档。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。