PHP对象编程问题,Call to a member function hello() on a non-object
<?php<br>
<br>
$instest = new test();<br>
$insobject = new object();<br>
$insobject->objectValue = "final";<br>
$instest->test();<br>
<br>
class test{<br>
var $testValue = "testValueins";<br>
function test(){<br>
print_r($insobject);<br>
$insobject->hello();<br>
}<br>
}<br>
<br>
class object{<br>
var $objectValue = "original";<br>
function hello(){<br>
echo $objectValue;<br>
}<br>
}<br>
<br>
?>
报错如下
Notice: Undefined variable: insobject in C:\wamp\www\zhebo\test.php on line 11
Call Stack
Notice: Undefined variable: insobject in C:\wamp\www\zhebo\test.php on line 12
Fatal error: Call to a member function hello() on a non-object in C:\wamp\www\zhebo\test.php on line 12
这有什么问题么,怎样才可以达到在实例里引用别的实例里的方法,或者有什么更好地解决方法?
我很急,希望大家可以帮忙。非常感谢啊。非常紧急。第一次用对象的思想编程还不太懂啊。









