Home >Backend Development >PHP Tutorial >PHP data types and judgment variable types
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.
Java code
$val1 = 1;
$val2 = 3.14;
$val3 = 'Who reads it and asks you to recite it, the water falls and the fragrance floats. ';
$val4 = array('aaa','bbb');
$val5 = true;
$val6 = function(){};
$val7 = null;
var_dump($val1) ;//Integer
echo '
';
var_dump($val2);//Floating point number
echo '
';
var_dump($val3);//String
echo '
';
var_dump($val4);//Array
echo '
';
var_dump($val5);//Boolean
echo '
';
var_dump($val6);//Object
echo '
';
var_dump($val7);//NULL
?>
Rendering:
PS: Since the encoding used is UTF-8, each Chinese character takes up 3 bytes, while English Each character occupies 1 byte.