ECshop 迁移到 PHP7版本时遇到的兼容性问题
在 PHP7 上安装 ECShop V2.7.3时,报错!
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ECS has a deprecated constructor in /usr/local/nginx/html/ecshop/upload/includes/cls_ecshop.php on line 25
这个报错的原因是 PHP7 不再支持与类名相同的构造方法,构造方法统一使用 __construct(), 比如下面的写法 PHP7 就会报这个错误。
class foo {
function foo() {
echo 'I am the constructor';
}
}
?>
回到 ecshop 我们看一下 cls_ecshop.php 文件的25行。如下
果然有与类名相同的构造方法,我们将构造方法 ECS 修改为 __construct,
回到 ecshop 的安装首页刷新,发现已经没有错误了。
单击下一步,报错
Deprecated: Non-static method cls_image::gd_version() should not be called statically in /usr/local/nginx/html/ecshop/upload/install/includes/lib_installer.php on line 31
这个报错的原因是静态调用非静态方法,比如下面的代码就会报这个错误
c