为了使类代码同时兼容 php4.0 和 5.0,可以采取以下的方式:
复制代码 代码如下:
<?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;
?>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!