7

ecshop 安装时”already defined constructor”

 3 years ago
source link: https://www.80shihua.com/archives/121
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

ecshop 安装时”already defined constructor”

作者: dreamfly 分类: ecshop 发布时间: 2014-12-03 22:15

出现这个错误,是php的兼容性问题,造成的原因是,原来写的代码是在php4的环境下运行的,现在挪到5之后,出现了2个构造函数,解决的办法只需要把__constructor()放到前面即可,如:

construct放到 和类名同名的构造函数之前。
<?php
class MyClass {
function __construct() { //for PHP5.0
echo 'this is class2 construct';
}
// 为了使类代码同时兼容 PHP4.0 和 5.0
function MyClass() { //for PHP4.0
$this->__construct();
}
}
$c3 = new MyClass;
?>

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用*标注


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK