May 10, 2021 PHP
String (string), Integer (integer), Float (floating-point type), Boolean (Boolean type), Array (array), Object (object), NULL (empty value).
A string is a sequence of characters, like "Hello world!".
You can put any text in single and double quotes:
$x = " Hello world! " ;
echo $x ; echo " <br> " ;
$x = ' Hello world! ' ;
echo $x ;
An integer is a number without a small number.
Integer rules:
In the following example we will test different numbers. PhP var_dump () function returns the data type and value of the variable:
Floating points are numbers with small parts, or exponential forms.
In the following example we will test different numbers. PhP var_dump () function returns the data type and value of the variable:
Boolean can be TRUE or FALSE.
Boolean type is usually used for conditional judgment. You'll learn more about condition control tutorials in the next chapters.
Arrays can store multiple values in a variable.
An array is created in the following instance, and then the PHP var_dump() function returns the data type and value of the array:
You'll learn more about arrays in the next chapters.
Object data types can also be used to store data.
In PHP, objects must be declared.
First, you must declare class objects using the class keyword. A class is a structure that can contain properties and methods.
Then we define the data type in the class, and then we use the data type in the instantiated class:
The PHP keyword this in the above example is a pointer to the current object instance and does not point to any other object or class.
You will learn more about objects in the next chapters.
The NULL value indicates that the variable has no value. NULL is a value with a data type of NULL.
The NULL value indicates whether a variable is an empty value. The same can be used for the difference between a data null value and a NULL value.
You can empty the variable data by setting the variable value to NULL:
The above is the commonly used data types in PHP, refer to the examples given in this section to familiarize yourself with the use of these data types, which is helpful for future learning!