php constant expression contains invalid operations

Solutions on MaxInterview for php constant expression contains invalid operations by the best coders in the world

showing results for - "php constant expression contains invalid operations"
Bruno
12 Jul 2018
1Parse error: syntax error, unexpected 'if' (T_IF) in C:\xampp\htdocs\study\insertdata.php on line 5
Issa
27 Nov 2016
1
2From the official Php documentation :
3
4Like any other PHP static variable, static properties may only be initialized using a literal or constant before PHP 5.6; expressions are not allowed. In PHP 5.6 and later, the same rules apply as const expressions: some limited expressions are possible, provided they can be evaluated at compile time.
5
6So you cannot initialize a static variable with another variable. Replace $appdata['id'] with a constant string or remove the static attribute.
7
8This is because all static declarations are resolved in compile-time, when the content of other variables is not known (see this other page of official doc).