What is the data type of a variable
In variables, because the variables occupy a different space unit (the site size is not the same), but also divided into several data types, like the supermarket packaging bags, there are several different types of goods, different products using various bags. We can get the memory consumed by the current PHP by using "Memory_get_usage".
Task
Let's compare the memory consumption!
In the editor on the right, we define four different data types, namely, String type, integer type, floating point type and array (these types are described in detail later).
1. In line 4th, define the String type "$var _string =" 123 ";"
2. The 7th line defines an integral type "$n = 123;"
3, the 10th line defines the float type "$f = 123.00;"
4, the 13th line defines the array "$var _array = Array (" 123 ");"
We can see the results of the output:
Initialization consumes 624056, strings consume 328, integers and floats are 288, and arrays consume 632.
Note: Depending on the operating system, PHP version, and how PHP works, it is possible to output different results.
Note: not original! If there is any infringement, please let us know!
PHP What is the data type of a variable