Some minor issues with PHP

  • 2020-03-31 20:59:21
  • OfStack

Sort out 2 for you to study

"===" VS "=="

For example, if you have a function that returns the following:
1. Number greater than 0
2. Less than 0
3, the number that is equal to 0.
4. False
If you want to capture failure, you must use === instead of ==
Because == is going to match the fourth case, it's going to match the third case, because 0 is also false!

In to one

$a = '2'; // character type 2
$b = 2; // numerical type 2
So $a is equal to $b, that's right, it's both 2
$a===$b, is not correct, because $a is character type $b is numeric type, the value is the same, but the type is different.


2. What do three Angle brackets do in PHP? < <"
 
$somevar = <<<someword 
put your code or words here 
someword; 

This is the code snippet. One advantage of using snippets in PHP is that when you need to output a piece of code (which can include multiple lines), the snippets can be kept in a more logical shape. Often used to insert HTML code.

Note that someword is an arbitrary character that represents the meaning of a tag. < < < Someword indicates the beginning of the tag, and the last someword indicates the end of the code segment. And this someword must be written in the top space (no Spaces or tabs or any other character in front of it)

You can use it for assignments that contain both single and double quotes

Related articles: