This works too? Is the string and 0 of all letters always equal? PHPcodeif (& quot; e & quot ;== 0) {echo & quot; Yes & quot ;;}# result: # Yes, & quot; e & quot; is it true if it is not a variable?
Is the string and 0 of all letters always equal? Explanations
PHP code
if("e" == 0){ echo "Yes";}#result:#Yes
------ Solution --------------------
"E" is not a variable in the memory. nothing .......
------ Solution --------------------
This way:
PHP code
Echo "e" = 0;
------ Solution --------------------
Php will automatically convert the type of the variable, and convert string to int if int and string are compared. as a result, all strings are 0, and the result is determined, you can use = full to determine
------ Solution --------------------
This solution is clearer:
Echo intval ('e'); # The conversion fails. the default value is 0 (print: 0)
Echo intval ('1ds2e'); # if there is an integer in the string, convert it to int (print: 1) from the first position)
Discussion
This way: PHP code
Echo "e" = 0;
------ Solution --------------------
This statement is wrong. "If there is an integer in the string, convert it from the first position to int (print: 1 )"
It should be like this:
If an integer appears in a string and the integer is at the starting position of the string, it is taken out and converted to an int.
Discussion
This solution is clearer:
Echo intval ('e'); # The conversion fails. the default value is 0 (print: 0)
Echo intval ('1ds2e'); # if there is an integer in the string, convert it to int (print: 1) from the first position)
Reference:
This way: PHP code
Echo "e" = 0;