php5.3之前版本升级至5.3以及更高版本后部分语法简单归纳

1. Deprecated: Assigning the return value of new by reference is deprecated in /usr/local/www/uugui/cake/libs/object.php on line 117

  将$dispatcher =& new Dispatcher();这样的语法改成$dispatcher = new Dispatcher();

2. Strict Standards: Non-static method DboFactory::getInstance() should not be called statically in /usr/local/www/uugui/app/common/public.inc.php on line 115

  这是php调用静态方法的语法。

  将$db = DboFactory::getInstance($config);这样的语法改成 $dboFactory = new DboFactory();$db = $dboFactory->getInstance($config); 或者将方法改成静态的(static修饰)

3. Deprecated: Function ereg() is deprecated in /usr/local/www/uugui/app/common/ipcheck.php on line 309

  ereg是php匹配正则表达式的方法,将其替换为preg_match,并在原正则表达式的首尾添加/

  将ereg方法用preg_match替换,$pattern = "^{$v}.*$";if(ereg($pattern,$tablename)) return "internal";改成$pattern = "/^{$v}.*$/";if(preg_match($pattern,$tablename)) return   "internal";

4. Fatal error: Call-time pass-by-reference has been removed in /usr/local/www/uugui/app/models/diagram.php on line 291

  将array_unshift (&$res,array("time"=>date("Y-m-d H:i:s",$curSec),"val"=>0)) ;改成array_unshift ($res,array("time"=>date("Y-m-d H:i:s",$curSec),"val"=>0)) ;

  被调用的方法的参数列表含有&$,将&$替换为$

5. Notice: Undefined variable: string2 in C:\Inetpub\wwwroot\index.php on line 28

  变量未定义或者初始化造成的错误

6. Warning: strftime(): It is not safe to rely on the system's timezone settings.

  在php头部添加方法date_default_timezone_set("PRC");

这些语法问题都可以通过设置php的报错等级将其屏蔽,php设置debug等级的方法可以是php.ini(此方法作用于全局),也可以是在php头部设置error_reporting()这个方法只对当前脚本有效,web工程中index页面中如用了此方法会将php.ini设置覆盖。php.ini还可以设置屏蔽所有debug,配置选项可参看http://php.net/manual/zh/ini.php

上一篇:Linux系统资源监控命令


下一篇:ELK学习笔记(一)安装Elasticsearch、Kibana、Logstash和X-Pack