Several methods for detecting data types in PHP (Summary) and several methods for data types
In JavaScript, typeof can be used to detect basic data types, and instanceof can be used to detect referenced data types. In PHP, there are also methods for detecting data types, as shown below:
1. gettype)
<? Php $ arry = array ('A', 'B', 'C'); echo gettype ($ arry); // array?>
2. Data type, quantity, and content of the output variable (var_dump)
View Source code printing Code help
<? Php $ str = 'Hello world'; var_dump ($ str); // string (11) "hello world"?>
3. check whether a variable is of the specified data type (is_array, is_string, is_int, is_double, etc.). If it is true, return 1. If it is false, return null.
View Source code printing Code help
<? Php $ num = 123; if (is_array ($ num) {echo 'This is an array';} else if (is_string ($ num )) {echo 'This is a string';} else if (is_int ($ num) {echo 'This is an integer';} else if (is_double ($ num )) {echo 'this is a floating point number ';}?>
Maybe your friend is looking for the answer to this question. Please share it with him!
The above several methods for detecting data types in PHP (Summary) are all the content that I have shared with you. I hope you can give us a reference and support for the help house.