In the PHP language environment that supports raw data type 8.
1, Four scalar types
boolean (boolean, true and false)
<? PHP // declare a boolean variable, use the keyword true or false, case-insensitive $ var = true ; ?>
integer (integer)
? < PHP // declare integer $ A = 1234; // Decimal $ B = -1234; // negative $ C = 0123; // octal (equivalent to decimal 83), preceded by a 0 (zero) as the identification. D $ = 0x1A; // hexadecimal (equivalent to decimal 26), with the front 0x identified. ?>
float (float, also called double)
<? PHP // declare float $ A = 1.234 ; $ b = 1.2e3 ; $ c = 7E-10 ; ?>
string (string)
<? PHP // declare string $ str = "PHP the Hello"; // double quotes if there are variables are parsed $ b = 'PHP the Hello' ; ?>
2 two match types
Array (array) <? PHP // declare an array format, which accepts any number of comma-separated key (key) => value (value) for $ Array = Array ( "the Hello" => "world", "world" = > "the Hello", ); // since PHP 5.4 from $ Array = [ "the Hello" => "world", "world" => "the Hello", ]; ?>
object (the object)
<? PHP // create an object class C { function do_c () { echo "Hello World" ; } } $ cInstance = new new C; // reference method $ cInstance -> do_c (); >?
3, a special type
resource (resources)
<? PHP // resource resource is a special variable, holding a reference to an external resource. Resources are created and used by special functions. ?>
NULL (no type)
<? PHP / * the following variables are considered NULL is assigned the value NULL has not yet been assigned to be unset () NULL type has only one value is not case-sensitive constant NULL * / $ var = NULL ; ?>
From the micro-channel public number: Programming Society
Advanced programmers daily book, please pay attention!