Data Types for PHP variables

Source: Internet
Author: User

Tag: Indicates that the assignment INF starts or the compound contains a null definition

One, type

scalar type : boolean integer floating-point string

Composite type : Array Object

Special type : resource null

1. Boolean type

True False

the following values are considered false and other values are considered true;

Boolean value false

integer value 0

floating-point 0

empty string and string 0

Empty array

Empty Object ( for PHP4 only )

Special type null

2. Integral type

positive and negative integers 0

maximum value of integral type Our maximum value is 2147483647 relative to the four-bit operating system

minimum value of integral type Our minimum value is -2147483647 relative to the four-bit operating system

you can use decimal  octal  hexadecimal Binary to represent an integral type

the value of an integral type cannot exceed the maximum minimum range If you exceed the will be resolved to be called float;

If you convert to a Boolean type in an integral type All values except 0 will be converted to true values

3. Floating-point type

is a decimal.

maximum number of floating-point numbers 1.7E 308 relative to the three-position system

the minimum value of the floating-point number -1.7E308 is exactly the decimal point

inf Infinity appears out of range    

4. String

string that can be defined with single, double quotes, and delimiters

string, no length limit

Single quotes :

single quotation mark does not parse variable, high efficiency, recommended use

Single quotation mark cannot contain single quotation marks, if need to display the single quotation mark need to add the escape character (\)

in single quotes, if the view escapes special characters , the backslash itself will be displayed.

single quotes can use escape string but you can only escape the single quotation mark and the escape character itself

Double quotes :

Double quote resolution variable

double quotation marks can parse special characters

double quotation marks if you parse the variable , add a grid or {} After the variable .

double quotation marks can be inserted into single quotation marks double quotation marks can be inserted in single quotation marks (can be plugged in)

but double quotes cannot be inserted in double quotes  Single quotes cannot be inserted in single quotation marks (cannot be inserted)

If you want to use double quotes in double quotes then use the escape character ( equivalent to lubricant )



How to declare : start with an identifier after the delimiter and end with this identifier

For example The following is the way to declare:



the end of the delimiter indicates that the first column must be written and must act as a single line cannot have any characters later

The identifier of the delimiter must follow the command specification in PHP , which can contain only alphanumeric underlines but cannot start with a number

The delimiter function is the same as the double quotation mark

Often used for text and large paragraph data output documents

5. Arrays   

An array is a collection of sets of numbers

to declare an array with array

Differentiate according to subscript

Associative arrays

Indexed array

Mixed arrays

Differentiate by dimension

One-dimensional arrays

Two-dimensional arrays

Multidimensional arrays

6. Objects

Objects and Classes

Resource Type ( Resource )

all the resources are stored in the computer.

Resource Type usually open a file or a picture or a database connection through a PHP function to generate


the meaning of floating clouds, the gods and Horses are clouds .

Null case insensitive null

the following conditions are considered null

assign a variable directly to a value of NULL

The declared variable has not been assigned a value

values destroyed by the unset function

Isset detects if the variable is declared if the declaration returns true otherwise returns false

Empty to determine whether the value of the variable is null 0 False if it is true otherwise returns false

We are simply introducing the data types of our PHP variables, and we will follow up on our arrays and our objects in detail, and now we need to understand the types of data types of our PHP variables, what they are about, what kind of things we have, and how we can use them, except for our arrays and objects, the rest must now be written down. Because we're going to introduce arrays and objects separately.

Data Types for PHP variables

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: 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.