Friday 22 December 2017

php - Failed to get an object property that containing ":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);


Object
output



JMenuSite
Object
(

[_items:protected] => Array

(
[101] => stdClass Object
(
[id] =>
101
[menutype] =>
mainmenu


Anyone know
what wrong with my code? Thanks.


class="post-text" itemprop="text">
class="normal">Answer





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.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...