无法获得包含“:protected"的对象属性. [英] Failed to get an object property that containing ":protected"
本文介绍了无法获得包含“:protected"的对象属性.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面的代码获取了对象的属性_items:protected
,但是没有运气.
I used the code below to get the object's property _items:protected
, but no luck.
$obj = JSite::getMenu();
print_r($obj->_items:protected);
对象输出
JMenuSite Object
(
[_items:protected] => Array
(
[101] => stdClass Object
(
[id] => 101
[menutype] => mainmenu
有人知道我的代码有什么问题吗?谢谢.
Anyone know what wrong with my code? Thanks.
推荐答案
您正试图从类外部访问受保护的属性. 只能从类本身或从该类继承的类内部访问受保护的属性.
You are trying to access a protected property from outside the class. A protected property can only be accessed from within the class itself or classes that inherit from that class.
阅读OOP访问修饰符.
Read up on OOP access modifiers.
这篇关于无法获得包含“:protected"的对象属性.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文