初学者 问个小问题

初学者 问个小问题

<html>
<head><title>Register</title></head>

<body>
<?php
print "begin";

class Person {
    function _construct($name)
    {
        $this->name = $name;
    }

    function getName()
    {
        return $this->name;
    }

    private $name;
};

$judy = new Person("Judy");
$joe = new Person("Joe");

print $judy->getName();
print $joe->getName();


print "end";
?>

</body>
</html>

为啥这段代买我只能显示beginend 中间那些name怎么都显示不出来

构造函数是 __construct 不是 _construct

[复制到剪切板]
CODE:
<?php
print "begin";

class 
Person {
    function 
__construct($name)
    {
        
$this->name $name;
    }

    function 
getName()
    {
        return 
$this->name;
    }

    private 
$name;
};

$judy = new Person("Judy");
$joe = new Person("Joe");

print 
$judy->getName();
print 
$joe->getName();


print 
"end";
?> ;


如履薄冰

yes,行了,谢谢斑竹