PHP对象编程有关问题,Call to a member function hello() on a non-object
程序员文章站
2023-12-30 14:09:58
...
PHP对象编程问题,Call to a member function hello() on a non-object
报错如下
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
这有什么问题么,怎样才可以达到在实例里引用别的实例里的方法,或者有什么更好地解决方法?
我很急,希望大家可以帮忙。非常感谢啊。非常紧急。第一次用对象的思想编程还不太懂啊。
$instest = new test();
$insobject = new object();
$insobject->objectValue = "final";
$instest->test();
class test{
var $testValue = "testValueins";
function test(){
print_r($insobject);
$insobject->hello();
}
}
class object{
var $objectValue = "original";
function hello(){
echo $objectValue;
}
}
?>
报错如下
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
这有什么问题么,怎样才可以达到在实例里引用别的实例里的方法,或者有什么更好地解决方法?
我很急,希望大家可以帮忙。非常感谢啊。非常紧急。第一次用对象的思想编程还不太懂啊。
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
- 最新文章
- 热门排行
推荐阅读
-
PHP对象编程有关问题,Call to a member function hello() on a non-object
-
PHP对象编程有关问题,Call to a member function hello() on a non-object
-
php中出现“Call to a member function Execute() on a non-object”的有关问题
-
PHP对象编程有关问题,Call to a member function hello() on a non-object
-
PHP对象编程问题,Call to a member function hello() on a non-object
-
PHP对象编程问题,Call to a member function hello() on a non-object
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论