Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP type matching

Tags:

php

In PHP, can someone explain to me why this resolves to true:

'NONE' == 0
like image 227
Putr Avatar asked May 27 '26 14:05

Putr


1 Answers

Because any non-numerical string cast to int will turn into 0.

If you don't want that to happen, use ===, the identical operator.

Read:
http://php.net/manual/en/language.operators.comparison.php
http://php.net/manual/en/types.comparisons.php

like image 167
NullUserException Avatar answered May 30 '26 03:05

NullUserException



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!