1

what would be the correct syntax to access body, as these are objects not arrays and the parent objects is 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"
    }

2 Answers 2

4

Protected (and same with Private) members/properties/variables of class are not directly accessible out of class or not accessible directly by class Object. So you need to write a Class Member Function for this to access Protected Object Array of that class

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
}
Sign up to request clarification or add additional context in comments.

Comments

2

You must write a function inside the class of your object to return 'body' value. Only functions belongs to the same class can access protected values of that class.

1 Comment

inherited or parent classes can access protected vars/methods. Private vars/methods are only accessible from the class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.