Php (3) PHP variable type

Source: Internet
Author: User
There are eight types of variables in 1PHP: & lt; 1 & gt; scalar type: boolean (boolean) integer (integer) float (float type, also double) string (string) & lt; 2 & gt; composite type: array (array) object (object) & lt; 3 & gt; special type: resource (resource) NULLPS: php variable class 1. there are eight variable types in PHP: <1> scalar type: boolean (boolean) integer (integer) float (float type, also "double") string (string) <2> compound type: array (array) object (object) <3> Special type: resource (resource) null ps: php variable type does not need to be declared, php automatically determines its type based on the context of the program running, isn't it smart? If you want to view the value of an expression, you can use the var_dump () function (). (1). boolean (boolean type) only has two values: true and false, 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. the integer value can be specified in decimal, hexadecimal or octal notation. example: 3. float (float type, also called "double") floating point number (also called floating point number, double number or real number) can be defined using any of the following syntax: Example: [php] (4) string is defined in three ways: single quotation marks, double quotation marks, and delimiters. Example: [php] "; Echo $ B; echo"
"; Echo $ c;?> Variable resolution: 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) defines array ([key =>] value ,...) // 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) to initialize an object, use the new statement to instance the object to a variable. Example: [php] Do_foo ();?> (7) resource to be written... (8) The special NULL value of NULL indicates that a variable does not have a value but does not exist. The only possible value of the NULL type is NULL. 'In the following cases, the variable is considered NULL: The value is NULL. Not assigned. Unset (). Example: [php] Two related functions: is_null (): Determine whether the variable is NUllunset (): delete the variable declaration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.