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 Types1.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.
<?php//output bool Type and String type = True;if ($r ==true) echo "This is true", else echo "This is false \ n"?? >
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 (<<<).
<?php//output bool Type and String type = True;if ($r ==true) echo "This is true", else echo "This is false \ n"; $str = ' I'll see you again. "Echo" $str <p> ";? >
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 integerThe integral type does not have to say more, look at the code:
<?php//output shaping $str1 = 1234567890; $str 2 = 0x1234567890; $str 3 = 01234567890; $str 4 = 01234567;echo "number 1234567890 different binary output: <p> "echo" decimal result: $str 1<br> "; echo" hexadecimal result is: $str 2<br> "; echo" octal result 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.
<?php//output floating-point echo ' <p> ', Echo ' pi 3 in writing mode:<p> '; Echo ' first: pi () = '. Pi (). ' <p> '; Echo ' second type: 3.1415926 = '. 3.1415926. ' <p> '; Echo ' third clock: 3145926E-11 = '. 314159265359E-11. ' <p> ';? >
not to be continued ...
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Chubby Learn PHP Summary 1-----PHP Data type