I have this controller in Code Igniter that begins with
class MyController extends CI_Controller {
private $data = array(
'importantValueToPassToViews' => $this->Animal->getPrey(),
);
...
I am getting an error on the line beginning with 'importantValueToPassToViews' (the third line).
Parse error: syntax error, unexpected T_VARIABLE
Why?
Because you can’t call a function in a class property definition. You can set it to a constant, or an array of constants.
You’ll need to do that in the constructor: