class a{
$array = array();
}
class b extends a{
**I need to get that array here !**
}
I'm not familiar with oops concept so please somebody help me
class a{
$array = array();
}
class b extends a{
**I need to get that array here !**
}
I'm not familiar with oops concept so please somebody help me
class a
{
public $_array = array();
}
class b extends a
{
public function getArray()
{
return $this->_array;
}
}
$x = new b();
echo $x->_array;
echo $x->getArray();
And read up on visibility in classes, it'll help understand when something is accessible from a child class, or only from the parent
You need to define your array as public or protected property of your class a
class a {
protected $array = array();
}
class b extends a {
public function __construct() {
$this->array = array('a', 'b', 'c');
}
}
There are three visibility levels of properties & methods: