为什么我的Code Igniter控制器出现意外的T_VARIABLE错误?

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:

<?php
class MyController extends CI_Controller {

    private $data = array();

    public function __construct()
    {
        parent::__construct();

        $this->data['importantValueToPassToViews'] = $this->Animal->getPrey();
    }
    // ...
 }