PHP的数据类型

PHP的数据类型有四种、8个

一、标量类型

  1. 整型(integer)

  2. 浮点型(floor)

  3. 字符串(string)

  4. 布尔型(bloon)

二、复杂类型

  1. 数组(array)

  2. 对象(object)

三、特殊类型

  1. NULL

  2. 资源(resource)

     1 <?php
     2 $a_bool  =  TRUE ;    // a boolean
     3  $a_str   =  "foo" ;   // a string
     4  $a_str2  =  'foo' ;   // a string
     5  $an_int  =  12 ;      // an integer
     6 
     7  echo  gettype ( $a_bool );  // prints out:  boolean
     8  echo  gettype ( $a_str );   // prints out:  string
     9 
    10 // If this is an integer, increment it by four
    11  if ( is_int ( $an_int )) {
    12      $an_int  +=  4 ;
    13 }
    14 
    15  // If $bool is a string, print it out
    16 // (does not print out anything)
    17  if ( is_string ( $a_bool )) {
    18     echo  "String:  $a_bool " ;
    19 }
    20  ?>
原文地址:https://www.cnblogs.com/chenyuphp/p/11758112.html