php基础_变量

<?php
    //Refer to document:http://cn2.php.net/manual/zh/function.settype.php 
//String Type
    $str = 'This is string.';
    echo gettype($str).':';
    var_dump($str);
    
    //Float Type
    $float = 3.1415926;
    echo gettype($float).':';
    var_dump($float);
    
    // Bool Type:
    $bool = TRUE;
    echo gettype($bool).':';
    var_dump($bool);
    
    //Interval Type
    $int = 65536;
    echo gettype($int).':';
    var_dump($int);
    
    //Double Type
    $Double = 88888888888888888888888888888888888888.88888888888888;
    echo gettype($Double).':'; 
    var_dump($Double);   
    
    // Null Type
    $null = NULL;
    echo gettype($null).':';
    var_dump($null);
    
    //Array Type:
    $array = array($int,$float,$str);
    echo gettype($array).':'; 
    var_dump($array);
    
    //Object Type:
    $object = (object)$int;
    echo gettype($object).':'; 
    echo get_class($object);
    var_dump($object);
    
    var_dump('follow constraint define:');
    
    $int = (int)123;
    var_dump($int);
    
    $float = (float)$int;
    var_dump($float);
    
    $str = (string)$float;
    var_dump($str);
    
    $arry = (array)$float;
    var_dump($arry);
    
    $bool = (bool)TRUE;
    var_dump($bool);
    
    $null = NULL;
    var_dump($null);
?>
php基础_变量

你可能感兴趣的:(PHP)