PHP Learning Notes (ii): Variable details, study notes
Introduction of PHP Variables
1. Grammar
Copy the Code code as follows:
PHP is a weakly typed language, and the variable type is determined by the stored value
Strongly typed language: int a = 1
$ Variable name = value
2. Naming rules
1). Cannot start with a number
2). Cannot use PHP operator (+-x/%&)
3). You can use the PHP keyword
4). Case-sensitive (PHP only variables, constants are case-sensitive)
5). Hump Naming method: AABBCC (first letter lowercase)
3. Variable variable
Variable names can be set dynamically, for example: $ $var
4. Reference Assignment
Copy the Code code as follows:
$a = 1;
$b =& $a; Assigns a value of $ A memory address to $b
$a = 2;
echo $b//Last value equals 1
Second, the variable data type
1. Four kinds of scalar
Copy the Code code as follows:
int (integer), bool (Boolean), float,double (floating-point penalty), String (string)
2, two kinds of compound type
Copy the Code code as follows:
Arrays: Array ()
Objects: Object
For example: $var = new Mysqlli (' localhost ', ' root ', ' 123455 ')
3, two kinds of special types
Copy the Code code as follows:
Resource (resources) For example: $var = fopen (' test.php ', ' R ')
Null (NULL type) is case-insensitive
Three, commonly used functions
Copy the Code code as follows:
Isset ()///variable exists and a value of NULL means that it does not exist
Unset ()//release variable
Var_dump ()//Check the type of variable or value
Empty ()//The variable does not exist or returns True when NULL
Settype ($a, int)//Set Variable type
GetType ()//Get variable type
Four, variable declaration method
Copy the Code code as follows:
$int = 10//integer 4-byte, Max 2³²
$float = 3.14e⁴//floating-point equals 3.14x10⁴
$bool = False//true is true
$str = "string"//double quotation mark can parse variable and escape character
You cannot use escape characters, but you can escape the single quotation mark itself for example $str = ' a\ ' a\ '
$str = ' string '
Declaring a string with a delimiter
http://www.bkjia.com/PHPjc/985259.html www.bkjia.com true http://www.bkjia.com/PHPjc/985259.html techarticle PHP Learning Notes (ii): Variable explanation, learning notes in detail one, PHP variable introduction 1, Syntax copy code is as follows://php is a weakly typed language, variable type is determined by the stored value ...