PHP构造函数 在一个类中调用另一类的构造函数怎么会出错???????

<?PHP
class Student
{
private $Name;
private $Age;
private $Sex;
function __construct($name,$age,$sex)
{
$this->Name = $name;
$this->Age = $age;
$this->Sex = $sex;
echo("被调用构造函数");
}

class person
{
function __construct()
{
Student::__construct("张",24,"男");
echo("调用构造函数");
}
}

$St = new person();
?>

运行后 怎么会有错???
错误信息如下:
Fatal error: Non-static method Student::__construct() cannot
be called statically, assuming $this from incompatible context
in E:\www\mytext\opp01.php on line 136

类的实例化不是这样的
Student::__construct("张",24,"男");
改成 new Student("张",24,"男")
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网