i have this type of array:-
i want to get array elemtn.
context_course Object
(
[_id:protected] => 15
[_contextlevel:protected] => 50
[_instanceid:protected] => 2
[_path:protected] => /1/3/15 [_depth:protected] => 3
)
the problem is [_id:protected]
i want to there value 15
how can i get if element is protected
.
thanks.
If a property is protected, it means the developer of the class doesn't want you to be able to freely directly access or modify its value from the public context.
If you analyze the class definition for this object, you will most likely find a method that will give you access to the value, for example it could be:
$obj->getId();
More info: Property Visibility
This is not an array, it is an object.
You will need to implement a public accessor
, also known as a getter
to access the object property.
class context_course
{
public function getId()
{
return $this->_id;
}
}