Android Programmer learns PHP Development (7)-strong variable type judgment-phpstorm

Source: Internet
Author: User
casts and variable type judgments

<?php/** * Cast and variable type judgment */$int = 1000; Echo GetType ($int);    Print Result: integer echo "<br>"; $str = (String) $int; Reshape the string echo GetType ($int);    Print Result: integer echo "<br>"; Echo GetType ($STR);    Print Result: string echo "<br>"; $int 2 = intval ($STR); String to reshape Echo GetType ($int 2);    Print Result: string echo "<br>"; $int 3 = (int) ($STR); String to reshape Echo GetType ($int 3);    Print Result: string echo "<br>";    $a = "456e3abchello123 world";    $b = 100; $c = $a + $b; In the process of adding, a does not add Var_dump ($c) as 456e3 scientific counting method;    Print Result: Float (456100) echo "<br>";        Gets the variable type of a and determines whether it is a string if (GetType ($a) = = "string") {echo "gettype = = string";    echo "<br>";        }//To determine whether a is null, true, or whether a is null if (Is_null ($a)) {echo "is_null = = true";    echo "<br>";        }else{echo "Is_null = = false";    echo "<br>"; }//Determine if A is an array, whether it is true, or whether a is an array if (Is_array ($a)) {echo "Is_array = = TRUE ";    echo "<br>";        }else{echo "Is_array = = false";    echo "<br>";        }//Determine if A is a string, whether it is true, or whether a is a string if (is_string ($a)) {echo "Is_array = = true";    echo "<br>";        }else{echo "Is_array = = false";    echo "<br>"; } is_bool (); Determines whether the Boolean value is Is_int (); Determine whether the plastic is_integer (); Determine whether the plastic is_long (); Determine whether the plastic is_float (); Determines whether the float type is_double (); Determines whether the float type is_real (); Determines whether the float type is_string (); Determines whether the string is Is_array (); Determine if the array is is_object (); Determines whether the object is Is_resource (); Determines whether the resource type is_null (); Determine if it is an empty is_scalar (); Judge whether it is a scalar is_numeric ();    Determines whether a variable is a numeric or numeric string. Is_callable (); Determine if the function name is valid


The above is the Android programmer to learn PHP development (7)-The strong variable type judge-phpstorm content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.