The result of non-null str==0 is True

Source: Internet
Author: User
 
  

Here bool actually is true .....
This is why


Reply to discussion (solution)

You so

 
  

Or
 
  

Look at the results, and then analyze it yourself.

You so

 
  

Or
 
  

Look at the results, and then analyze it yourself.
But does the OP 0 in PHP represent an empty string?

Like upstairs

That's how I analyze it.

echo $str > 0 results null
echo $STR < 0 results NULL
echo $str = = 0 Result 1

Because $str is a string, itself is not a number, so as a number $str is indeed false,php false==0 is true

Refer to this post for me. When I search for a database, the varchar field uses col=0 to search for the result incorrectly swapped with Col is null after correct
It should be the same.
http://bbs.csdn.net/topics/390529217

Upstairs explanation makes sense.


It's a string I thought I'd convert 0 to a string first!!!!!

= = Do compare when type conversion string and numeric comparison if the string is not 0 all converted to 0 to do the comparison result is certainly true you can try ' = = = ' To do the comparison will understand


It's a string I thought I'd convert 0 to a string first!!!!!

Oh, let you use those to do the experiment you can not see, there is no way


You so

 
  

Or
 
  

Look at the results, and then analyze it yourself.
But does the OP 0 in PHP represent an empty string?
Hey
  • 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.