首页 > 代码库 > php基础03:数据类型

php基础03:数据类型

<?php
    
    // day01:数据类型
    
    //01.字符串
    $x = "hello world";
    echo $x;
    echo "<br>";
    $y = ‘hello world‘;
    echo $y;
    echo "<br>";
    var_dump($y);
    echo "<hr>";

    //02.整数
    $num1 = 555;
    var_dump($num1);
    echo "<br>";
    echo $num1;
    echo "<br>";
    $num2 = -555;
    var_dump($num2);
    echo "<hr>";

    //03.浮点数
    $float1 = 55.55;
    var_dump($float1);
    echo "<hr>";

    //04.逻辑
    $b1 = true;
    $b2 = false;
    var_dump($b1);
    echo "<br>";
    var_dump($b2);
    echo "<hr>";

    //05.数组
    $arr1 = array(‘name‘ => "gaoxiong");
    echo "<pre>";
    var_dump($arr1);
    echo "</pre>";
    $arr2 = array("BMW","SAAB","VOVOL");
    echo "<pre>";
    var_dump($arr2);
    echo "</pre>";
    echo "<hr>";

    //06.对象
    Class Car {
        function Car($color="green"){
            $this->color = $color;
        }
        function what_color(){
            return $this->color;
        }
    };
    $newCar = new Car("blue");
    var_dump($newCar);
    echo "<hr>";

    //07.null
    $d = "hello world";
    $d = null;
    var_dump($d);
    echo "<hr>";


?>

 

php基础03:数据类型