访问body的正确语法是什么,因为这些是对象而不是数组,并且父对象是node:protected
CourseObjectContent Object
(
[node:protected] => stdClass Object
(
[nid] => 9397
[type] => book
[language] =>
[uid] => 1
[status] => 1
[created] => 1364217732
[changed] => 1367581312
[comment] => 0
[promote] => 0
[moderate] => 0
[sticky] => 0
[tnid] => 0
[translate] => 0
[vid] => 9406
[revision_uid] => 1
[title] => title text
[body] => "body text"
}
Protected(与Private一样)类的成员/属性/变量不能直接在类外访问,也不能被类Object直接访问。所以你需要写一个类成员函数来访问这个类的保护对象数组
class CourseObjectContent {
protected $node;
//member function to access 'protected' members of class
function accessObjectArray(){
//TODO:Your code to access protected object array
}
//other member functions
}
必须在对象的类中编写一个函数来返回'body'值。只有属于同一类的函数才能访问该类的受保护值。