Maison >développement back-end >tutoriel php >对象实例化后访问不了
class person{
var $name;
function say(){
echo "hello!";
}
}
$P = new person;
$p->name="TOM";
$p->say();
?>
Notice: Undefined variable: p in I:\www\PHPnow-1.5.6.4237493736\Package\htdocs\DemoClass.php on line 10
Fatal error: Call to a member function say() on a non-object in I:\www\PHPnow-1.5.6.4237493736\Package\htdocs\DemoClass.php on line 10
哪里出错了,新手求教,我照着书上码的。
$P = new person;
$p->say();
php 的变量是区分大小写的
$P 和 $p 是两个变量