php, why 0 = = ' abc ' is set up?

Source: Internet
Author: User
0== ' is set up I do understand that
0== ' ABC ' also set up don't understand, please advise!

Reply content:

0== ' is set up I do understand that
0== ' ABC ' also set up don't understand, please advise!

Aha, the first two days just looked at the relevant article, this is because you are a number and a string to compare, PHP will convert the string into a number and then compare .
The rules for PHP conversion are: If the string starts with a number, the first number is taken as the result of the conversion, and if none is output 0.
For example: 123abc after the conversion should be 123 , and abc then, of 0 0==0 course, this is set up!
Refer to the Official manual: If you compare an integer and a string, the string is converted to an integer.
PS: @gaosboy is a '00'=='000' comparison of two strings, and the official manual is explained.

$a = ' abc '; $b = (int) $a; echo $b; if (0 = = $b) {    //set}

Execute it and you'll know.

See here, think it is time to take a closer look at the PHP manual ~ ~ ~

Test everyone, do not do testing, directly say Var_dump (' ABCDE ') of the print results is what

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.