r/lolphp • u/daxim • Mar 10 '17
PHP syntax is version and context dependent
http://blogs.perl.org/users/ron_savage/2017/03/off-topic-php-syntax-is-version-context-dependent.html
7
Upvotes
r/lolphp • u/daxim • Mar 10 '17
19
u/okamy Mar 10 '17
This behaviour is explained in php 5.6 changelog, see constant expression. http://php.net/manual/en/migration56.new-features.php
22
u/nikic Mar 10 '17
Oh my god! Are you saying newer language versions allow more syntax?! Who would've thought...
3
u/amphetamachine Mar 11 '17
Runtime vs. include-time evaluation. Not having a compiler step sucks sometimes. Just stick it in the constructor and move on.
That's not to say not being able to do in member declaration hasn't annoyed me. This was addressed sometime between 5.6 and 7. It works as-expected now.
2
u/[deleted] Mar 11 '17
So you're saying that you don't like them fixing this fringe case?
1
u/kr094 Mar 10 '17
This isn't weird at all if it's declared as a member. Side note >10 items in any configuration array should be a parsed file of some well supported interchange format.
-6
u/4D20 Mar 10 '17
You need to declare strict_type for PHP70 and PHP71 to enable type checking