Syntax error when defining an array as a class property
...
public $aSettings = array(
'BindHost' => "127.0.0.1",
'Port' => 9123,
'MaxFileSize' => (5 * (1024 * 1024)), // unexpected "(" here
'UploadedURL' => "http://localhost",
'UploadPath' => dirname(__FILE__) . "/upload",
'UploadMap' => dirname(__FILE__) . "/uploads.object",
'RegisterMode' => false
);
...
This is my code, right from the class. I have a problem:, "unexpected ( on line 22"line 22 - MaxFileSize.
I don't see a problem with this, is this a limitation of Zend Engine? Or I'm blind.
You cannot use inconsistent values when initializing class properties in PHP versions earlier than 5.6.
They are initialized at compile time, in which PHP will not perform any calculations or execute any code. (5 * (1024 * 1024))is an expression that requires an assessment that you cannot do. Either replace it with a constant value 5242880, or do the calculation in __construct.
PHP 5.6, 2014 , " " , , .