Because PHP determines the variable type and converts it as needed (usually), it is not obvious what type of variable is given at a certain time point. PHP includes several functions to determine the type of a variable, such as gettype (), is_array (), is_float (), is_int (), is_object (), and is_string ().
The code is as follows:
$ S = "this is a string ";
$ I = 9;
$ Arr = array (2, 4, 6 );
Is_string ($ s); // returns TRUE, indicating that $ s is a string variable.
Is_string ($ I); // returns FALSE, indicating that $ I is not a string variable.
Is_array ($ arr); // returns TRUE, indicating that $ arr is an array.
Is_array ($ s); // returns FALSE, indicating that $ s is not an array
$ Str = "this is a string ";
$ Int = 9;
$ Bool = FALSE;
Echo "\ $ str:". gettype ($ str );
Echo"
";
Echo"
";
Echo "\ $ int type:". gettype ($ int );
Echo"
";
Echo"
";
Echo "\ $ bool type:". gettype ($ bool );
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service