Heim > Artikel > Backend-Entwicklung > PHP对象编程有关问题,Call to a member function hello() on a non-object
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 /> ?>