JavaScript data Type Summary of PHP eight basic data types

Source: Internet
Author: User

Four types of scalar:

    • Boolean (Boolean)
    • integer (integer type)
    • float (floating-point, also called double)
    • String (String)

Two kinds of composite types:

    • Array (arrays)
    • Object (objects)

Finally, there are two special types:

    • Resource (resources)
    • null (NULL)

To ensure the readability of the Code, this manual also describes some pseudo-types:

    • Mixed
    • Number
    • Callback

and the pseudo-variable $ ....

You might also read some references to the double-precision type. In fact double and float are the same, because of some historical reasons, both names exist at the same time.

The type of the variable is usually not set by the programmer, but rather is determined by the context in which PHP is used according to the variable.

Note: If you want to see the value and type of an expression, use var_dump ().

If you just want an easy-to-read type of expression for debugging, use GetType (). To view a type, do not use GetType (), and use the is_type function. Here are some examples:

Copy the Code code as follows:


$a _bool = TRUE; A Boolean
$a _str = "Foo"; A string
$a _str2 = ' foo '; A string
$an _int = 12; An integer
Echo GetType ($a _bool); Prints Out:boolean
Echo GetType ($a _str); Prints out:string
If This is a integer, increment it by four
if (Is_int ($an _int)) {
$an _int + = 4;
}
If $bool is a string, print it out
(Does not print out anything)
if (is_string ($a _bool)) {
echo "String: $a _bool";
}
?>


If you want to cast a variable to a type, you can use a cast or settype () function on it.

Note that the variable will behave differently depending on its current type. See type tricks for more information. In addition, you can refer to the PHP type comparison table to see different types of comparisons between the examples.

The above describes the JavaScript data type PHP Eight basic data type summary, including the JavaScript data type content, I hope to be interested in PHP tutorial friends 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.