Variable type PHP judgment variable type implementation code

Source: Internet
Author: User
PHP includes several functions that can determine the type of variable, such as: GetType (), Is_array (), Is_float (), Is_int (), Is_object (), and is_string ().

Copy the Code code 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;
The type of echo "\ $str is:". GetType ($STR);
echo "
";
echo "
";
The type of echo "\ $int is:". GetType ($int);
echo "
";
echo "
";
The type of echo "\ $bool is:". GetType ($bool);
?>

The above describes the variable type PHP judgment variable type implementation code, including the content of the variable type, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.