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.