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
这有什么问题么,怎样才可以达到在实例里引用别的实例里的方法,或者有什么更好地解决方法?
我很急,希望大家可以帮忙。非常感谢啊。非常紧急。第一次用对象的思想编程还不太懂啊。










