Failed to get an object property that containing “:protected” [duplicate]

寵の児 提交于 2019-12-13 10:40:00

问题


I used the code below to get the object's property _items:protected, but no luck.

$obj = JSite::getMenu();
print_r($obj->_items:protected);

Object output

JMenuSite Object
(
    [_items:protected] => Array
        (
            [101] => stdClass Object
                (
                    [id] => 101
                    [menutype] => mainmenu

Anyone know what wrong with my code? Thanks.


回答1:


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.

Read up on OOP access modifiers.



来源:https://stackoverflow.com/questions/17751438/failed-to-get-an-object-property-that-containing-protected

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!