...
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 might run into invalid syntax in Python when you’re defining or calling functions. For example, you’ll see a SyntaxError if you use a semicolon instead of a colon at the end of a function definition: >>>. >>> def fun(); File "<stdin>", line 1 def fun(); ^ SyntaxError: invalid syntax.
When you attempt to assign a value to pass, or when you attempt to define a new function called pass, you’ll get a SyntaxError and see the "invalid syntax" message again. It might be a little harder to solve this type of invalid syntax in Python code because the code looks fine from the outside.
Often, the cause of invalid syntax in Python code is a missed or mismatched closing parenthesis, bracket, or quote. These can be hard to spot in very long lines of nested parentheses or longer multi-line blocks.
The other type of SyntaxError is the TabError, which you’ll see whenever there’s a line that contains either tabs or spaces for its indentation, while the rest of the file contains the other. This might go hidden until Python points it out to you!
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 value 5242880
or 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With