I have a method within a class that returns a single array. This method is called within other methods inside the same class. Rather than keep defining $data at the begining of each method, is there a way og defining it at the begining of the extended class? Here is an example of what I'm trying to achieve [simplified]
class Myclass extends AnotherClass
{
protected $data = $this->getData(); // this does not wwork
public function aMethod()
{
$data = $this->getData();
$data['userName'];
// code here that uses $data array()
}
public function aMethod1()
{
$data = $this->getData();
// code here that uses $data array()
}
public function aMethod2()
{
$data = $this->getData();
// code here that uses $data array()
}
public function aMethod2()
{
$data = $_POST;
// code here that processes the $data
}
// more methods
}