This code throws a parsing error that I don't understand why.
function t(){ return 'g'; } function l(){ static $b = t(); return $b; } l();
The question is why?
static values ββof the variables are filled in at the parsing stage, so they cannot contain inconsistent values.
static
You can implement value initialization using the following:
function l(){ static $b; if (!$b) $b = t(); return $b; }
Quote from the manual:
Note:Attempting to assign values ββto these [static] variables that are the result of expressions will result in a parsing error.
Note:
Attempting to assign values ββto these [static] variables that are the result of expressions will result in a parsing error.
(my emphasis)
cf http://www.php.net/manual/en/language.variables.scope.php Example # 7
Source: https://habr.com/ru/post/1389956/More articles:Error Message MessageBodyReader Resteasy - javaVisual Studio 2010 Pro not ending debug mode when closing an application - c #prevent dragging a window into ios5 mobile browser - javascriptUnderstanding the template in preg_match_all () Function call - phpCommit redistribution without interactive forwarding? - gitVisual Studio 2010 projects are always expanding - visual-studio-2010cout does not work as a regular user for Visual C ++ Express 2010 on Windows 7 - c ++Python on Netbeans 7.1 - pythonVisual C ++ 2010 Express for Win32 Project link only works as an administrator - c ++Building Java with generics giving me irrelevant arguments - javaAll Articles