


In php, 0 == false, 0 == false will be equal, and false != false is the reason.
First look at a special case:
var_dump(0 == 'false'), returns bool(true), PHP determines that 0 is equal to any string;
var_dump(0==='false'), returns bool( false), the types and values must be equal if they are congruent.
var_dump(0 == false), returns bool(true),
The reasons for the above results (translated from php official documentation):
1. For bool type:
When you output the bool type or When used in a statement, it will be converted into a number , true becomes 1, and false becomes 0.
For example, $a = true; var_dump($a+1), returns (int)2; $a is converted to 1, and the sum is 2;
A bool variable expresses a true value, and Rather than expressing a 0 or 1; Boolean types are not iconic constants, they have values.
2. String type:
php will always automatically try to convert strings into numbers. For example, var_dump('abc'+3'), returns int(3),
First 'abc' is converted into the number 0, and the addition becomes 3;
Method to detect the type of variable:
1. var_dump ($param) , will return the type and value of the variable.
2. Use is_int(), is_bool(), is_string(); functions to return true and false,
commonly used type conversion methods.
Variable $param
Integer type (int)$param
Character type (string)$param
Boolean type (bool)$param
Another way to convert to Boolean type: $a = !5, $a is false ,$a = !!5,$a is true;
The above introduces the reasons why 0 == false, 0 == false will be equal, and false ! = false in php. , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

A dump file usually refers to a binary file, also known as a dump file or core dump file. This kind of file is generated by the computer system when it encounters a serious error or abnormal situation. It is used to store the status, stack, registers, memory images, logs and other information of the system or application.

In computers, dump means "dump" in Chinese, which generally refers to exporting and dumping data into files or static forms, that is, saving dynamic (volatile) data into static data (persistent data). There is no need to dump data like programs that are originally stored in storage media (such as hard disks).

Detailed explanation of the meaning of true in PHP function In PHP, true is a Boolean value, representing the state of "true" or "yes". Using true in a function is usually used to express that a condition is true or to return a success status. This article will explain in detail the meaning of true in PHP functions from different perspectives, and give specific code examples. 1. Conditional judgment when true is returned: In PHP functions, true is usually used in conditional judgment to indicate that the condition is true. For example: functioni

Title: What does true mean in PHP functions? In PHP programming, true represents true in a Boolean value, usually indicating the state of "true". When true is used in a function, it is usually used to determine whether a condition is true or to perform some operation. The following will use specific code examples to illustrate what true means in PHP functions. example:

In Java development, there is a seemingly simple, but there are a lot of topics and questions on the Internet, that is, what is the difference between equals() and the == operator ==: The operator is used to compare whether the addresses of two objects are equal equals( ): method is used to compare whether the contents of two objects are equal. Today's content introduction, which takes about 9 minutes. To better understand this difference, let us look at an example: Stringstr1=newString("Hello");Stringstr2=newString(" Hello");System.out.println(str1.equals(str2));//output trueSystem

The project recently added an IP black and white list function. I found that if the IP filtering interceptor returns false, the front end will display cross-domain. After trying to modify the MVC configuration class, I found that it still didn't work. Finally, I added a judgment to the interceptor @OverridepublicbooleanpreHandle. (HttpServletRequestrequest,HttpServletResponseresponse,Objecthandler)throwsIOException{//-----------Just add this-----------if(!(handlerinstanceo

Linux param refers to the "module_param" function, which is used to pass command line parameters; when programming in user mode, command line parameters can be passed through the parameters of "main()", and when writing a kernel module, pass "module_param()" to pass parameters.

The redis-dump tool is used to build the environment for data migration in the cluster: 192.168.19.201redis-cluster637970017002rvmredis-dump192.168.19.202redis-cluster637970017002192.168.19.203redis-cluster637970017002 due to the installation of the redis-dump tool You need to use rvm and gem tools, so they must be installed in advance. 1. Install the dependency packages required to install rvm and other tools in advance #yum-yinstallzlibzlib-develpcrepcre
