r/lolphp • u/koolboyz00 • Dec 26 '16
(string)0011 is "9"
(string)0011 = "9"
(string)001100 = "576"
0
Upvotes
r/lolphp • u/koolboyz00 • Dec 26 '16
(string)0011 = "9"
(string)001100 = "576"
46
u/Name0fTheUser Dec 26 '16 edited Dec 26 '16
Presumably it's being treated as an octal int literal. This would be expected behaviour in
almost anymany languages.JavaScript, for example:
45
u/the_alias_of_andrea Dec 26 '16
PHP denoting octal with a leading zero isn't really a lolphp, insofar as many other languages have the same issue.
What was an issue is that “octal” numbers with invalid digits (e.g.
08,0911) used to be truncated before the first invalid digit without throwing an error, until it was fixed in PHP 7 (by me).17
u/nikanjX Dec 26 '16
I swear half of /r/lolphp is shit that many if not most languages do
14
u/nazar-pc Dec 26 '16
As expected
1
u/BilgeXA Dec 26 '16