1

Get object 's array value in php

 $obj = new Basecamp($bcUrl, $bcApikey, 'X', 'simplexml');

while print the object

    print_r($obj);

Get array as following:

Basecamp Object
(
    [request:protected] => 
    [baseurl:protected] => https://test.basecamphq.com/
    [format:protected] => simplexml
    [username:protected] => 5d4dsh8745hkf876kjdfhkfsd843ea46a
    [password:protected] => X
    [request_body:protected] => 
)

I want to take value of [baseurl:protected] i.e get 'https://test.basecamphq.com/' only from this object.

3 Answers 3

4

[baseurl:protected] means that the object has a property called baseurl which has a visibility of protected. That means you can specifically not access it directly from outside the class. Look in the documentation of the class how you're supposed to access it. It probably has a method like getBaseurl that allows you to do so.

Sign up to request clarification or add additional context in comments.

Comments

1

Assuming, its basecamp-php-api you're using, Basecamp class has a getBaseurl() method with which the base URL is retrievable.

If it's not, you could extend the Basecamp class like this in order to access protected members:

class MyBasecamp extends Basecamp {
   public function getBaseurl() {
      return $this->baseurl;
   }
}

Comments

0

You cannot get value of baseurl property of BaseCamp object outside of it, because it is protected. You need to use some getter method.

Comments

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.