Summary of 1-PHP data types

Source: Internet
Author: User
Summary: 1-PHP data types: PHP supports eight primitive types, including four scalar types: boolean, integer, float, and double) and string (string type); two composite types: array and object; two special types: resource and NULL.

1.1 scalar data type 1.1.1 boolean type

Generally, the Boolean type is applied to the expressions of the condition or loop statement. in the if condition statement, the following checks whether the value in the variable $ r is true, and then outputs the corresponding information.

 
Note: In PHP, a boolean value is considered as false in some special cases. in these special cases, the values are: 0, 0.0, "0", blank string (""), declare only arrays without value assignment, etc.

Note: $ is the identifier of a variable. all variables start with $. the $ symbol should be used to declare variables or call variables.

1.1.2 string type (string)

In PHP, there are three methods to define strings: single quotation marks ('), double quotation marks ("), and delimiters (<).

 ";?>
If you need to use the swivel chair character, you only need to escape the single quotation mark "'" when using single quotation marks. when using double quotation marks, you need to note a lot of escape, the backslash \ is usually used for escape.

1.1.3 integer

You don't need to talk about integer types. check the code:

 "; Echo" decimal result: $ str1
"; Echo" hexadecimal format: $ str2
"; Echo" the result of the octal sequence is: "; if ($ str3 = $ str4) {echo '& str3 = & str4 = '. $ str3;} else {echo '$ str3! = & Str4';}?>
1.1.4 floating point type

The floating-point data type can be used to store numbers or decimals. in versions earlier than PHP4.0, the floating-point data type is marked as double, also known as double-precision floating-point numbers. Floating point numbers can be written in either the standard format 3.1415 or the scientific notation format 3.58E1.

 '; Echo' write method in 3 of the circumference rate:

'; Echo' first: pi () = '. pi ().'

'; Echo 'second type: 3.1415926 ='. 3. 1415926 .'

'; Echo 'third clock: 3145926E-11 ='. 314159265359E-11 .'

';?>


Not complete...



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.