PHP data types include: string, integer, floating point number, Boolean, array, object, NULL.
How to determine the variable type, use the var_dump function.
The var_dump function is to determine the type and length of a variable and output the value of the variable. If the variable has a value, it will lose the value of the variable and return the data type.
<meta charset="UTF-8"> <?php $val1 = 1; $val2 = 3.14; $val3 = '阅谁问君诵,水落清香浮。'; $val4 = array('aaa','bbb'); $val5 = true; $val6 = function(){}; $val7 = null; var_dump($val1);//整数 echo '<br>'; var_dump($val2);//浮点数 echo '<br>'; var_dump($val3);//字符串 echo '<br>'; var_dump($val4);//数组 echo '<br>'; var_dump($val5);//布尔 echo '<br>'; var_dump($val6);//对象 echo '<br>'; var_dump($val7);//NULL ?>
Rendering:
PS: Since the encoding used is UTF-8, each Chinese character occupies 3 bytes, while each English character occupies 1 byte.