Types in PHP. Break the pattern

0 like 0 dislike
3 views
<?php<br/>$result = (0 == "php") ? TRUE : FALSE;
var_dump($result);

// Why TRUE???
by | 3 views

1 Answer

0 like 0 dislike
Because PHP. Get used to inconsistencies. The template itself will still totally break =)
\r
\rwww.php.net/manual/en/language.operators.comparison.php
\r
If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically.

\r
\rwww.php.net/manual/en/language.types.string.php#language.types.string.conversion
\r
The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero).
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
asked May 22, 2019 by Dubrovin
110,608 questions
257,186 answers
0 comments
28,667 users