PHP string = side effects of comparison operators _ PHP Tutorial

Source: Internet
Author: User
Side effects of PHP string comparison operators. The copy code is as follows: $ a212345678912000005; $ b212345678912000001; var_dump ($ a $ B); the output of this code is bool (true). This indicates that the two conclusions are obtained. The code is as follows:


$ A = '000000 ';
$ B = '000000 ';
Var_dump ($ a = $ B );


The output of this code is bool (true), indicating that the two are equal. similar features are applicable when the 3rd in_array () function parameters are false or not set. the reason is that you first determine whether the string is a number, then convert it to long or double (C data type), and then judge-use zendi_smart_strcmp. however, the comments in the source code indicate that the declaration considers overflow,

The code is as follows:


} Else if (dval1 = Dval &&! Zend_finite (dval1 )){
/* Both values overflowed and have the same sign,
* So a numeric comparison wocould be inaccurate */
Goto string_cmp;
}


Dval1 and Dval are the values after the two strings are converted to the double type, but why? Maybe this judgment is incorrect. further research...

Solution: Use the three equal signs "=" to replace the two equal signs "=". The in_array () function sets the third parameter to true: in_array ('Val', $ array, true ).

The http://www.bkjia.com/PHPjc/320772.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/320772.htmlTechArticle code is as follows: $ a = '000000'; $ B = '000000'; var_dump ($ a = $ B); the output of this code is bool (true ), it indicates that this judgment will conclude that the two are in the same phase...

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.