Hi,

I have data like this -

Someting Object
(
    [_values:protected] => Array
        (
            [key1] => something,
            [key2] => something else,
etc...

How do i access that _values:protected part? I tried $name->_values:protected, but it gives me an error.

Thanks

Recommended Answers

All 3 Replies

Post the error.. Have you tried making a public function, returning then echoing the value you want?

echo $name -> functionName(); 
or
protected _values = whatever;
echo $name -> _values;

protected values can only be accessed by the class or any class that extends.

class foo{
	protected $value = 'test';
	
        //only this class can call privates ^_^
	private $val2 = 'hohoho';
	
	public function getVal () {
		return $this->value;
	}
}

class bar extends foo{
	
	public function getFooVal(){
		return $this->value;
	}
	
	public function getFooVal2(){
		return $this->$val2;
	}
	
}

$a = new foo();

$a->getVal(); //ok

$a->value; //nope

$b = new bar();

$b->getFooVal(); //ok

$b->getFooVal2(); //nope
Member Avatar for diafol

how about giving the real code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.