doc-en
doc-en copied to clipboard
Static variable initializers can now contain arbitrary expressions.
From manual page: https://php.net/language.variables.scope
Example 7 says that static $int = sqrt(121); is wrong. This has not been updated for 8.3, which allows static variables to be initialised with arbitrary expressions.
There is also a Note: slightly further down that states that " Static declarations are resolved in compile-time." My understanding (which isn't certain enough to be writing the necessary docs) is that the declarations are now resolved the first time the function is executed (and if the expression defining the value recurses on the function call itself, the first time the expression completely evaluates provides the value).