my friend and me found this while debugging an application
<?php
echo "check: " . ('x' == 0);
?>
This code prints 1 (so, it is true, x equals to 0). Can somebody explain why it is? I think may be I dont understand something in php rules... or may be it is a bug?
Thank you.
The string is converted to a number using "type juggling". This is shown in the documentation , too.
For this particular case, the string doesn't start with a number, so it becomes equal to 0 when cast.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.