First look at a special case:
Var_dump (0 = = ' false '), returns BOOL (true), PHP determines 0 equals any string, Var_dump (0=== ' false '), returns BOOL (false), and the congruent contains type and value to be equal.
Var_dump (0 = false),
In PHP because it is a weakly typed language, the different types of values can be implicitly converted, making false,null, ", 0, ' 0′ The comparison of these values is somewhat confusing, now summarizes:Equal judgment' = = NULL = = 0 = = False
Php 0, null, empty, null, false, detailed description of the string relationship. I encountered a strange problem in a project, and it took me a lot of time to solve it. The final debugging found that it was a judgment problem-about 0 and ''(null
: This article mainly introduces the relationship between 0, null, empty, and false in PHP empty strings. For more information about PHP tutorials, see. // Determine the relationship between 0 and '', null, empty, and false
$ A = 0;
Echo
The PHP empty string describes the relationship between 0, null, empty, and false. If the method function is used incorrectly or is used less, if the logic sequence of several method functions is wrong, it may be a vulnerability and cannot be found
The empty () function is used to determine whether a string is empty
As long as the variable is 0,null, ", False,empty () is judged to be true.
$num 1= '; $num 2=0; echo $num 1== $num 2; Echo ''; echo $num 1=== $num 2? ' 1 ': ' 0
In a project encountered a strange problem, it cost me a lot of time is not resolved, the final debugging found is the question of judgment-about 0 and "(empty single quotation marks, for good see I added a space), I found 0==" incredibly set up,
In PHP, when the variable is 0, the variable is "equal to" false "at the same time. how can we distinguish between 0 and false? This is useful in some condition statements. This article will give an example. First, check the code. the function of
In-depth understanding of the relationship between 0, null, empty, null, false, and strings in php
// Judge the relationship between 0 and ''and empty null false. start //
If ('safdasefasefasf' = 0 ){
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.