Start with <?php and end with?>
Semicolon
Function Execution statement: must add a semicolon. is to add a semicolon to the code statement.
Code Structure statement: Do not add semicolons. Just like the function {} curly braces are not appended
Comments
...... Single-line Comment
/*/... * * Multi-line Comments (multiple lines of comments cannot be nested in multiple lines of comment)
#...... Script comments
/**......*/Document Comments
Note: It is often customary to write comments to the top or right of the code, i.e. write the comments before writing the code
variables
A variable is a container that is temporarily stored
PHP is a weak type of language
The variable starts with a $ symbol followed by a letter, a number, an underscore, but not a number.
<php $a = "Hello"; $b = +; $c =true;? >
Variable variable
$a = "Hello";
$ $a = "PHP"; Actual: $ $a is $ ($a), i.e. $hello
Note: You cannot add other characters between two $ characters and must be close to, such as $my $ A = = $myhello This does not exist
<? $a= "Hello"; $$a= "php"; Var_dump ($a); Hellovar_dump($$a); PHPvar_dump($hello
?>
Ways to manipulate variables
unset () Delete variable
Isset () detects if the variable is set
Empty () detects if the variable is null
Var_dump () detects the variable type and value, which is the type and value of the input variable
<?PHP$a= "Hello"; $b=""; Var_dump($a); Var_dump($b); Var_dump(Empty($b));//$b is empty, empty ($b) returns True Var_dump(isset($c));//$c Undefined, isset ($c) returns false unset($b);//delete variable?>
A reference to a variable
& Symbols
<?PHP$a=10;$b=&$a;Echo $a." </br> "; Echo $b." </br> ";//$b the same address as $ A$a=100;Echo $a." </br> ";// -Echo $b." </br> ";// -$b=200;Echo $a." </br> ";// $Echo $b." </br> ";//200
From the above can be seen, re-assign one of the values, the other changes
?>
1. Only variables have addresses
$b = &10; 10 is not a variable, error
2. One variable changes and the value of the other variable changes
3. When using unset (), if there is a referential relationship, deleting a variable simply deletes the reference relationship
4. A variable can have only one reference address, if you give it two addresses, then the following address overwrites the previous address, the reference relationship of the preceding address is broken
<?PHP//the address of a variable to two or more variables, changing one of the other full changes$a=10;$b=&$a;$c=$a; or$a=10;$b=&$a;$c=$b;//two different addresses to the same variable, after giving the overwrite first given, first give the broken reference relationship$a=10;$c=111;$b=&$a;$b=$c//b before receiving the address of a, now receive the address of C, whichever is later?>
3 Basic PHP syntax