0

http://sandbox.onlinephpfunctions.com/code/00df9cc6697316297118b6a073b0e4784fcd5ad0

How come, that in PHP the following is true?

if ("*" == 0) { echo "What the heck?"; }

This makes absolutely no sense?

Thommy Tomka
  • 332
  • 1
  • 3
  • 14
  • Because one is a string and one is an integer so the string is cast to an integer which can only be 0 since its not a number. http://php.net/manual/en/language.types.type-juggling.php – AbraCadaver Mar 20 '19 at 21:02
  • It's a string, what did you expect? Same thing with "A" https://3v4l.org/u7RhJ – Andreas Mar 20 '19 at 21:03
  • 4
    "This makes absolutely no sense?" --- what makes absolutely no sense is to compare a string and a number and to expect a reasonable result back. – zerkms Mar 20 '19 at 21:03
  • 2
    If you would do === it wouldn't be true – Alex Mar 20 '19 at 21:04

0 Answers0