对象实例化后访问不了
时间:2021-07-01 10:21:17
帮助过:7人阅读
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 是两个变量