首頁 > 後端開發 > php教程 > PHP对象编程有关问题,Call to a member function hello() on a non-object

PHP对象编程有关问题,Call to a member function hello() on a non-object

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
發布: 2016-06-13 11:33:56
原創
898 人瀏覽過

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

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

相關標籤:
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
javascript - js正規符合特定字串
來自於 1970-01-01 08:00:00
0
0
0
為什麼說非物件呼叫成員函數fetch()
來自於 1970-01-01 08:00:00
0
0
0
資料庫設定檔必須要用二維數組
來自於 1970-01-01 08:00:00
0
0
0
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板