Hi Alain

> > https://wiki.php.net/rfc/arbitrary_static_variable_initializers
> > https://externals.io/message/118976
>
> Could I suggest that you make something like the following throw an error:
>
> function foo($i) {
>     static  $a = $b + 1;
>     static  $b = $i;
> }
>
> You could try to reorder but what if the second static had been:
>
>     static  $b = $i + $a;
>
> Yes: stupid, but someone will try it.

With this RFC static variables are evaluated in the normal order of
execution. The first statement will throw an undefined variable
warning and result in 1. The second one will be initialized to
whatever $i contains. This is consistent with non-static variables.

Ilija

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to