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