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 easily. Tangle ~ Find out which method function is used online. if the logic sequence of several methods and functions is incorrect, the vulnerability may be discovered easily. Tangle ~
Find out which senior person has come up with relevant conclusions online! However, it does not seem very comprehensive. I have improved it here for your reference only.
The code is as follows:
// Determine the relationship between 0 and '', null, empty, and false
$ A = 0;
Echo "relationship between 0 and'', empty, null, and false :";
If ($ a = ''){
Echo "0 = '';";
} Else {
Echo "0! = '';";
}
If (trim ($ a) = ''){
Echo "trim (0) = '';";
} Else {
Echo "trim (0 )! = '';";
}
If (strval ($ a) = ''){
Echo "strval (0) = '';";
} Else {
Echo "strval (0 )! = '';";
}
If ($ a = ''){
Echo "0 = '';";
} Else {
Echo "0! = '';";
}
If (empty ($ )){
Echo "0 is empty ;";
} Else {
Echo "0 is not empty ;";
}
If (is_null ($ )){
Echo "0 is null ;";
} Else {
Echo "0 is not null ;";
}
If (is_numeric ($ )){
Echo "0 is numeric ;";
} Else {
Echo "0 is not numeric ;";
}
If (is_string ($ )){
Echo "0 is string ;";
} Else {
Echo "0 is not string ;";
}
If (! $ ){
Echo "0 is false ;";
} Else {
Echo "0 is not false ;";
}
// Judge the relationship between ''and 0, null, empty, and false.
$ A = '';
Echo "the relationship between'' and 0, empty, null, and false :";
If ($ a = 0 ){
Echo "'' = 0 ;";
} Else {
Echo "''! = 0 ;";
}
If (intval ($ a) = 0 ){
Echo "intval ('') = 0 ;";
} Else {
Echo "intval ('')! = 0 ;";
}
If (empty ($ )){
Echo "'' is empty ;";
} Else {
Echo "'' is not empty ;";
}
If (is_null ($ )){
Echo "'' is null ;";
} Else {
Echo "'' is not null ;";
}
If (is_numeric ($ )){
Echo "'' is numeric ;";
} Else {
Echo "'' is not numeric ;";
}
If (is_string ($ )){
Echo "'' is string ;";
} Else {
Echo "'' is not string ;";
}
If (! $ ){
Echo "'' is false ;";
} Else {
Echo "'' is not false ;";
}
// Determine the relationship between null and '', 0, empty, and false
$ A = null;
Echo "relationship between null and'', 0, empty, and false :";
If ($ a = ''){
Echo "null = '';";
} Else {
Echo "null! = '';";
}
If ($ a = 0 ){
Echo "null = 0 ;";
} Else {
Echo "null! = 0 ;";
}
If ($ a = ''){
Echo "null = '';";
} Else {
Echo "null! = '';";
}
If ($ a = 0 ){
Echo "null = 0 ;";
} Else {
Echo "null! = 0 ;";
}
If (strval ($ a) = ''){
Echo "strval (null) = '';";
} Else {
Echo "strval (null )! = '';";
}
If (intval ($ a) = 0 ){
Echo "intval (null) = 0 ;";
} Else {
Echo "intval (null )! = 0 ;";
}
If (empty ($ )){
Echo "null is empty ;";
} Else {
Echo "null is not empty ;";
}
If (is_numeric ($ )){
Echo "null is numeric ;";
} Else {
Echo "null is not numeric ;";
}
If (is_string ($ )){
Echo "null is string ;";
} Else {
Echo "null is not string ;";
}
If (! $ ){
Echo "null is false ;";
} Else {
Echo "null is not false ;";
}
Echo "";
The output result is:
Based on the output results, I want to clearly understand the approximate relationship between null strings, 0, null, empty, and false, and flexibly use the methods in the above code during development, with good logic, there should be no problems.
Click to download relevant source code
Bytes. Tangle ~ Search for a high image on the internet...