Home > Backend Development > PHP Tutorial > PHP data types_PHP tutorial

PHP data types_PHP tutorial

WBOY
Release: 2016-07-15 13:22:08
Original
1084 people have browsed it

PHP data types

PHP supports eight primitive types (types).

Four scalar types:

string (string)
  • integer (integer)
  • float (floating point type, also called double)
  • boolean (Boolean)
  • Two composite types:

    array (array)
  • object (object)
  • Two special types Type:

    resource (resource)
  • NULL (empty)
  • View variable type

    You can easily view a variable through the gettype() function Type:

    Tips

    Due to historical reasons, if it is float type data, the gettype() function returns It's double, not float.
  • If you want to see the value and type of an expression, please use the var_dump() function.
  • Judge the variable type

    If you want to determine the next logical action by judging the variable type, do not use gettype(), but use the is_type series of functions:

    < ;?php$var_int = 12; // If $var_int is int type, this is added if (is_int($var_int)) { $var_int = $var_int+4;}echo $var_int; // Output 16?>

    www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/447016.htmlTechArticlePHP data types PHP supports eight primitive types (types). Four scalar types: string (string) integer (integer) float (floating point type, also called double) boolean (Boolean type)...
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template