PHP judgment Variable Type implementation Code _php Foundation

Source: Internet
Author: User
PHP includes several functions to determine the type of variable, such as: GetType (), Is_array (), Is_float (), Is_int (), Is_object (), and is_string ().
Copy Code code as follows:

<?php
$s = "This is a string";
$i = 9;
$arr = Array (2,4,6);
Is_string ($s); Returns true to indicate that $s is a string variable
Is_string ($i); Returns false to indicate that $i is not a string variable
Is_array ($arr); Returns true to indicate that $arr is an array
Is_array ($s); Returns false to indicate that $s is not an array
$str = "This is a string";
$int = 9;
$bool = FALSE;
The type of echo "\ $str is:". GetType ($STR);
echo "<br/>";
echo "<br/>";
The type of echo "\ $int is:". GetType ($int);
echo "<br/>";
echo "<br/>";
The type of echo "\ $bool is:". GetType ($bool);
?>

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.