Stupid bird learning php (2) how to use variable 1. variable Declaration 1. methods for declaring variables in php: & nbsp; $ var123; 2. php is a weak language, and the variable type is determined by the stored & #20540; & nbsp; note: Java is a strong language, to declare a variable, you must first specify the type 3. isset () and unset () & nbsp; is stupid bird learning php (2) how to use variables
I. variable declaration
1. method for declaring variables in php: $ var = 123;
2. php is a weak language, and the variable type is determined by the stored value.
Note: Java is a strongly-typed language. to declare a variable, you must specify the type first.
3. isset () and unset ()
Isset (): determines whether a value exists; unset (): removes the value of the variable.
2. variable naming
1. you must use "$" before the variable. this symbol must be included in the declaration and use.
2. it cannot start with a number.
3. you cannot use the operator number in php +-*/% &
4. you can use the system keyword as the variable name.
5. in php, only variables and constants are case-sensitive, while others are case-insensitive.
2. variable
1. the variable name of a variable can be dynamically set and used
2. variables can be referenced and assigned values (one with the reference in Java)
III. types of variables
1. as mentioned earlier, php is a weak type language and its type is determined by the storage value.
2. php has 8 medium types:
2.1) four scalar:
Integer: int integer boolean: bool boolean floating point: float double real string: string
2.2) two composite types
Array: array object: object
2.3) two special types
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?>
IV. declaration of various types of variables