...
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, straight from a class. The problem I have is the "unexpected ( on line 22", line 22 being MaxFileSize.
I can’t see a problem with it, is this a Zend Engine limitation? Or am I blind.
You cannot use non-constant values while initializing class properties in PHP versions earlier than 5.6.
These are initialized at compile time, at which PHP will do no calculations or execute any code.
(5 * (1024 * 1024))is an expression that requires evaluation, which you cannot do there. Either replace that with the constant value5242880or do the calculation in__construct.PHP 5.6, introduced in 2014, allows “constant scalar expressions” wherein a scalar constant or class property can be initialized by an evaluated expression in the class definition rather than the constructor.