欢迎光临
我们一直在努力

ecshop在php5.3以上版本运行中的各种报错处理

php5.3以上环境中,安装ecshop的时候,会遇到报错提示,如下:

gd_version()

1.Strict Standards: Non-static method cls_image::gd_version() should not be called statically in F:\xampp\htdocs\ecshop\default\install\includes\lib_installer.php on line 31

解决:从提示中找到install/includes/lib_installer.php中的第31行

return cls_image::gd_version();

然后在找到include/cls_image.php中的678行,发现gd_version()方
法未声明静态static,所以会出错。这时候只要:

1)将function gd_version()改成static function gd_version()即可。

2)或者将install/includes/lib_installer.php中的第31行return cls_image::gd_version();改成:

$p = new cls_image();
return $p->gd_version();

不支持JPEG

2.检测环境的时候提示:是否支持 JPEG是不支持的。

解决:查看发现有libjpeg.lib库,GD2库也有,都加载了,也都正常。查看ecshop源代码发现install/includes/lib_installer.php中第100行,JPEG写成了JPG,正确的应该是:

$jpeg_enabled = ($gd_info['JPEG Support'] === true) ? $_LANG['support'] : $_LANG['not_support'];

为何说ecshop写错了,因为我打印数组$gd_info的时候,里面的键名是:JPEG Support。而$gd_info数组里的值都是直接调用系统环境变量的。

preg_replace()

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in F:\xampp\htdocs\ecshop\default\includes\cls_template.php on line 300

大致内容是preg_replace函数中的e修饰符已过时,使用preg_replace_callback函数代替。
关于此修饰符,参见:
http://www.php.net/manual/zh/reference.pcre.pattern.modifiers.php

解决:找到 includes\cls_template.php 中的300行代码

return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);

改成

return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);

//自定义函数的形参由你自己命名,你只需满足
preg_replace_callback 的回调函数需要接受一个数组就行了

Only variables should be

Strict Standards: Only variables should be passed by reference in F:\xampp\htdocs\ecshop\default\includes\cls_template.php on line 423

解决:找到 includes\cls_template.php 中的423行代码

$tag_sel = array_shift(explode(' ', $tag));

改成

$tag_arr = explode(' ', $tag);
$tag_sel = array_shift($tag_arr);

另一个地方同样修改(includes\lib_main.php”文件的1329行):

//$ext = end(explode('.', $tmp));
$ext_bak = explode('.', $tmp);
$ext = end($ext_bak);

原因:array_shift的参数是引用传递的,5.3以上默认只能传递具体的变量,而不能通过函数返回值,后台更新缓存后正常。

mktime()

Strict standards: mktime(): You should be using the time() function instead

2处地方:admin\sms_url.php 和 admin\shop_config.php

错误行:$auth = mktime();
PHP手册里 http://cn2.php.net/manual/en/function.mktime.php 有个Note:
As of PHP 5.1, when called with no arguments, mktime() throws an E_STRICT notice: use the time() function instead.
自从PHP5.1起,调用这个函数不传递参数,会出现一个 notice
@mktime()
前面加@屏蔽mktime出错时提示

constructor

Strict Standards: Redefining already defined constructor for class alipay in F:\xampp\htdocs\ecshop\default\includes\modules\payment\alipay.php on line 85

…多行报错提示省略

这个错误跟PHP“类”中的构造函数有关,PHP早期版本是是用跟类同名的函数作为构造函数,后来又出现了使用 __contruct() 作为构造函数,这2个函数可以同时存在。

到了PHP5.4版本,对这2个函数在代码中的先后顺序有了严格的要求。
在PHP5.4版本以上,必须 __contruct() 在前,同名函数在后,否则就会出现上面的错误提示。

解决:includes\modules\payment 文件夹下的所有文件(upop.php除外),把

function alipay()
{
}

function __construct()
{
$this->alipay();
}

调换一下位置,其他几个文件也是一样操作。

赞(0) 打赏
未经允许不得转载:程序开发爱好者 » ecshop在php5.3以上版本运行中的各种报错处理
分享到: 更多 (0)

网站设计及开发、微应用及微网站开发、微信公众平台开发、 HTML5手机网站开发、网络整合营销、APP开发、软件开发及企业电商服务

联系我们