Stupid birds Learn PHP (ii) How to use variables
I. Declaration of variables
1. methods of declaring variables in PHP: $var = 123;
2. PHP is a weakly typed language, and the type of the variable is determined by the stored value
Note: Java is a strongly typed language, declaring a variable must first specify the type
3. Isset () and unset ()
Isset (): Determine whether the value exists; Unset (): Remove the value of the variable
Two. Naming of variables
1. be sure to use "$" before the variable, declare and use this symbol.
2. You cannot start with a number.
3. Cannot use the arithmetic symbol in PHP +-*/% &
4. You can use the System keyword as the variable name
5. Only variables and constants in PHP are case-sensitive, others do not differentiate
Two. Variable variable
1. variable names for a variable can be set and used dynamically
2. Variable can be referenced assignment (and a reference in Java)
Three. Types of variables
1. As mentioned earlier, PHP is a weakly typed language, and its type is determined by the stored value
2. PHP has 8 types:
2.1) Four kinds of scalars:
Shape: int integer Boolean: bool Boolean float: float double real string: string
2.2) Two types of composite
Array: Array object: Object
2.3) Special types in two
Resource type: Resource NULL type: null
int (1) [1]=>int (2) [2]=>int (3)} $var =new mysqli ("localhost", "root", "root", "newcms"); Var_dump ($var); Object (mysqli) #1 (0) {} $var =fopen ("1.php", "R"), Var_dump ($var); Resource (3) of type (stream) $var =null;var_dump ($var); Null?>
Four. Variable declarations of various types