Damn it.

Source: Internet
Author: User
 
  


Why the output is 311 ... What the hell happened to daddy?


Reply to discussion (solution)

$huancuns ==0 not set up?
$huancuns = = = 0 Not set up

$huancuns ==0 not set up?
$huancuns = = = 0 Not set up



' [{' id ': ' 1 ', ' time ': ' 0 '},{' id ': ' 2 ', ' time ': ' 0 '}] ' this equals 0???

The string is converted to a number, and if the string does not begin with a number, the result is 0.

What's so strange about this?

Var_dump (' [{' "id": "1", "Time": "0"},{"id": "2", "Time": "0"}] ' = = 0);
BOOL (TRUE)

What's so strange about this?

Var_dump (' [{' "id": "1", "Time": "0"},{"id": "2", "Time": "0"}] ' = = 0);
BOOL (TRUE)



Study, Ah, it is better to remove = = 0

This kind of judgment should have been written.
if (empty ($huancuns)) {
Processing for empty-time
}

Determine if the variable is null,0 "" "0" ... With empty ($STR)

PHP comparison, when the two ends of the end is a number, will be converted to a number comparison.
Can write like this

            if (! $huancuns) {                echo ("311");            } else{                Echo ("211");            }

either empty or!
= = and no () will produce strange phenomena ...
This is related to the mechanism.

$huancuns ==0//Remove the condition may be to convert the string into a number, but the conversion failed, directly to the 0.
  • 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.