PHP supports a total of 8 primitive types, including 4 winning types, namely: Boolean (Boolean), Integer (Shape), float/double (floating point), and String (string), two composite types: Array (array) and object (objects) ; Two special types, namely: resource (Resource) and null.
1.1 Scalar data types
1.1.1 Boolean type
Typically, Boolean types are used in expressions that are applied to a condition or loop statement, and the following in the IF condition statement determines whether the value in the variable is true, and then outputs the respective information.
Note: In PHP, not only false values are false, in some special cases the Boolean value is also considered false, these special cases are: 0, 0.0, "0", a blank string (""), only declare an array with no assignment, and so on.
Description: The dollar sign $ is the identifier for the variable, and all variables begin with the $ character, whether declaring a variable or calling a variable, should use the $ symbol.
1.1.2 The String type (string)
In PHP, there are 3 ways to define strings, namely single quotation marks ('), double quotation marks ("), and delimiters (<<<).
";? >
If you need to use a swivel chair character, use single quotation marks to escape only single quotes "'", when using double quotation marks, there is a lot to be aware of escaping, usually using backslashes \ to escape.
1.1.3 Integer Integer
The integral type does not have to say more, look at the code:
The result of "; echo" decimal is: $str 1
The result of "; echo" hexadecimal is: $str 2
The result of "echo" octal is: "; if ($str 3 = = $str 4) { echo ' &str3=&str4= '. $str 3;} else{ echo ' $str 3! = &str4 ';}? >
1.1.4 floating Point type
Floating-point data types can be used to store numbers or to hold decimals, and in previous versions of PHP4.0, floating-point markers are double, also called double-precision floating-point numbers, but not both. Floating-point numbers have two writing formats, one of which is the standard format: 3.1415; and one is the scientific notation format: 3.58E1.
'; Echo ' pi 3 in writing:'; Echo ' the first type: pi () = '. Pi (). '
'; Echo ' the second type: 3.1415926 = '. 3.1415926. '
'; Echo ' third: 3145926E-11 = '. 314159265359E-11. '
';? >
Not to be continued ...
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.