PHP Data Type _php Tutorial

Source: Internet
Author: User
Tags scalar

PHP data type

PHP supports eight primitive types (type).

Four types of scalar:

String (String)
  • Integer (integer type)
  • Float (floating point type, also double)
  • Boolean (Boolean)
  • Two kinds of composite types:

    Array (arrays)
  • Object (Objects)
  • Two special types:

    Resource (resources)
  • Null (empty)
  • View variable types

    The GetType () function makes it easy to see the type of a variable:

    Tips

    For historical reasons, if the data is float type, the GetType () function returns a double instead of float.
  • If you want to see the value and type of an expression, use the Var_dump () function.
  • Judging variable types

    If you want to determine the next logical action by judging the variable type, do not use GetType () and use the Is_type series function:

    !--? php$var_int = 12;//if $var _int is of type int, this is an addition if (Is_int ($var _int)) {$var _int = $var _int+4;} echo $var _int;//output?-->

    http://www.bkjia.com/phpjc/ 447016.html www.bkjia.com true http://www.bkjia.com/phpjc/447016.html techarticle php Data type PHP supports eight primitive types (type). Four scalar types: string (String) integer (integer) float (floating-point, also Double) Boolean (Boolean) ...

  • Related Article

    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.