Take a look at this code, please:
$array = array(
'action' => function () { echo "this works"; }
);
class Test {
public $array = array(
"action" => function () { echo "this doesn't"; }
);
}
The first function literal parses fine, but the second - the one inside the class - triggers a syntax error:
Parse error: syntax error, unexpected 'function' (T_FUNCTION)...
Can somebody explain this to me? Is this a bug?
EDIT: This is the latest PHP: 5.6.6
Try it like this, let me know if this works for you
I dont have chance to test Your code on PHP 5.6.6, but I think this code resolve Your problem.
From the class it's a property !
Rule from properties :
http://php.net/manual/en/language.oop5.properties.php