Summary of seven data types of PHP


To get started with PHP, you must first learn to build an environment, and then learn basic syntax. The foundation of PHP includes data types, operators, variables and constants.

In this article, we mainly understand what data types are. Data type refers to a general term of the same kind of data, which is generally described as XX data type.

For example, if integers and decimals are numbers, we will collectively call them digital data types. In PHP, data types are divided into seven categories:

PHP has seven data types. Seven types:

  1. character string,
  2. Integer,
  3. float,
  4. Boole,
  5. Array,
  6. Object,
  7. resources.

Examples of data types for PHP are as follows:



A string of characters enclosed in single or double quotation marks*/

echo "12rqwr#@%";

echo 'rq#@wr12%';


It refers to an integer. It cannot have a decimal point. It can be positive or negative*/

echo 3124;

echo -3124;


An integer or decimal with a decimal point, and an exponent*/

echo 0.35;

echo 3.0;


Refers to yes or no, represented by true and false*/

echo True;

echo False;


Refers to a set of data, including string, integer, floating point, etc*/



Contains the structure of properties and methods. See the object section for details*/

class ClassName extends AnotherClass


 function __construct(argument)


  # code...



/*Null value:

Indicates that there is no value and the data is empty*/

echo null;


In the above example, two basic knowledge points are supplemented: annotation and printout. Comments are intended to be remarks and have no impact on the program, but to facilitate developers to understand the program. The printout is intended to show the results.

There are two kinds of comments for PHP, for example:

//Double slashes are used for single line notes

/*This symbol is used to annotate multiple lines*/

There are three types of printouts for PHP, for example:


/*Display string type, integer type

Floating point type, null*/

echo 123;

echo "string";

echo 0.35;

echo null;

//Display array type


//Display array type,显示判断条件的是与非

//Than print_ R () shows more details



Another thing to note is that every complete sentence of code must be written in English; End, otherwise an error will occur.

The above are the details of the seven data types that novices must know when getting started with PHP. If you have any supplement, you can directly contact the developeppaer editor.

Recommended Today

Beautify your code VB (VBS) code formatting implementation code

However, does have many new functions that VB6 does not have. The automatic typesetting of code is one, which is the function we want to realize today – VB code formatting.Let’s look at the effect: Before formatting: Copy codeThe code is as follows: For i = 0 To WebBrowser1.Document.All.length – 1 If WebBrowser1.Document.All(i).tagName = […]