how to get if array key is protected?

可紊 提交于 2019-12-02 03:48:53

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