PHP supports eight primitive types

Source: Internet
Author: User
PHP supports eight primitive types. PHP supports eight primitive types. Four scalar types: boolean -- trueorfasle, both of which are case-insensitive integer-32-bit systems; range:-2147483648 ~ + 21474836 PHP supports eight primitive types
PHP supports eight primitive types.

Four scalar types:


Boolean -- true or fasle is case insensitive.

Integer-32-bit system, range:-2 147 483 648 ~ + 2 147 483 647

Float (float) (floating point number, also called "double")-32-bit system, range: 1.7E-308 ~ 1.7E + 308

String)


Two composite types:

Array)

Object)


There are two special types:

Resource)

NULL --
The variable is considered NULL in the following cases:


The value is NULL.

Not assigned.

Unset ().


Syntax
Is a case-insensitive keyword, null, NULL, or Null.


========================================================== ======================================
Boolean)

When converted to boolean, the following values are considered FALSE:


Boolean value FALSE

Integer value 0 (0)

Floating point value: 0.0 (0)

Blank string and string "0"

Array without member variables

Objects without cells

Special type NULL (including unset variables)

All other values are considered to be TRUE (including any resources ).
-1 is considered TRUE like other non-zero values (both positive and negative values!


========================================================== ============================
Integer
If you specify a number that exceeds the integer range, it will be interpreted as float. Similarly, if the calculation result exceeds the integer range, float is returned.

========================================================== ======================================
Floating point type
Floating point numbers (also known as floats, doubles, or real numbers) can be defined using any of the following syntax:


$ A = 1.234;
$ A = 1.2e3;
$ A = 7E-10;
?>

========================================================== =====
String
Note: PHP does not impose an implementation range on the size of a string, so there is no reason to worry about long strings.

Strings can be defined using three literal methods:

Single quotes (')

Double quotation marks (")

Delimiter (<)



Single quotes --
1. the value of variable $ a in '$ A' is not output, and only $ a is output.
2. to output \ and single quotes ('), add the escape character \

Double quotation marks --
1. the value in variable $ a in double quotation marks "$ a" is output.
2. escape characters
Escape characters

Sequence meaning
\ N line feed (LF or ASCII character 0x0A (10 ))
\ R press enter (CR or ASCII character 0x0D (13 ))
\ T horizontal tab (HT or ASCII character 0x09 (9 ))
\ Backslash
\ $ Dollar Sign
\ "Double quotation marks
\ [0-7] {} the regular expression sequence matches a character represented by the octal symbol
\ X [0-9A-Fa-f] {} this regular expression matches a sequence of characters represented by a Hexadecimal Symbol


Delimiters (<)--
The row of the end identifier cannot contain any other characters, except a semicolon. This especially means that the identifier cannot be indented, and there cannot be any spaces or tabs before or after the semicolon. It is also important to realize that the first character before the end identifier must be a line break defined in your operating system. For example, \ r is used in a Macintosh system.

  






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.