Php (3) PHP variable types 1. PHP variable types:
<1> scalar type:
Boolean (boolean)
Integer)
Float (float type, also "double ")
String (string)
<2> compound type:
Array)
Object)
<3> Special types:
Resource)
NULL
PS: php variable types do not need to be declared. php automatically determines the type based on the context of the program running. is it very smart? Awesome
To view the value of an expression, you can use the var_dump () function ().
(1). boolean (boolean)
Only two values are true or false, which are case-insensitive. all values other than 0 are true and 0 is false.
Boolean (boolean) is often used for process control for condition judgment.
Example:
[php]
2. integer)
The integer value can be specified in decimal, hexadecimal, or octal notation.
Example:
?>
3. float (float type, also "double ")
Floating-point numbers (also called floating-point numbers, double-precision numbers or real numbers) can be defined using any of the following syntax:
Example:
[php]
(4) string (string)
There are three methods to define a string: single quotes, double quotation marks, and delimiters.
For example:
[Php]
"; Echo $ B; echo"
"; Echo $ c;?>
Variable parsing:
Single quotes: If the definition content contains variables, the variable name is directly output, rather than the content.
Double quotation marks: If the defined content includes variables, the content is output directly.
Delimiters: If the defined content includes variables, the content is output directly.
You can use {} to specify the variable range in double quotation marks and delimiters.
[php]
(5) array () (array) definition
Array ([key =>]
Value
,...
)
// The key can be integer or string.
// Value can be any value
For example:
[php]
"bar", 12 => true); echo $arr["foo"]; // bar echo $arr[12]; // 1 ?>
(6) object)
To initialize an object, use the new statement to instance the object to a variable.
Example:
[Php]
Do_foo ();?>
(7) resource)
Waiting for writing...
(8) NULL
A special NULL value indicates that a variable does not have a value but does not exist. The only possible value of the NULL type is NULL. '
The variable is considered NULL in the following cases:
The value is NULL.
Not assigned.
Unset ().
For example:
[php]
Two related functions:
Is_null (): determines whether the variable is NUll.
Unset (): delete variable declaration
The above is the php (3) PHP variable type content. For more information, please follow the PHP Chinese network (www.php1.cn )!