Android程式員學PHP開發(6)-字串數組對象資源-PhpStorm

來源:互聯網
上載者:User
var_dump()方法真好用。
簡單地說,var_dump()方法會返回變數的資料類型和值。
複雜點說,var_dump()方法是判斷一個變數的類型與長度,並輸出變數的數值,如果變數有值輸的是變數的值並回返資料類型.此函數顯示關於一個或多個運算式的結構資訊,包括運算式的類型與值。數組將遞迴展開值,通過縮排顯示其結構。

<?php    /**     * 變數類型     * 字串String     * 順帶介紹逸出字元     */    $int = 10; // 列印結果:10    $str2 = "a"; // 列印結果:a    $str3 = "this is a 'demo'"; // 列印結果:this is a 'demo'    $str4 = "this is a \"demo\""; // 列印結果:this is a "demo"    $str5 = "this is a $int"; // 列印結果:this is a 10    $str6 = 'this is a $int'; // 列印結果:this is a $int    //$str7 = "this is a $intttttt"; // 列印結果:會報錯 , 因為沒有這個變數    $str8 = "this is a {$int}ttttt,\\,\n,\r,\t"; // 列印結果:this is a 10ttttt,\, , ,    $str9 = 'this is a {$int}ttttt,\\,\n,\r,\t'; // 列印結果:this is a {$int}ttttt,\,\n,\r,\t    $str10 = <<<hello        <<<是定界字串的內容,這裡面隨便寫.....$int 出現 hello; 也不怕,因為需要頂格寫,才表示結束hello;    // 列印結果:<<<是定界字串的內容,這裡面隨便寫.....10 出現 hello; 也不怕,因為需要頂格寫,才表示結束    /**     * 變數類型     * 數組Array     */    $arr = array(1,2,3,4,5); // array(5) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) }    /**     * 對象     * Object     */    class Person{        var $name;        var $age;        var $sex;        function say(){        }        function eat(){        }    }    $person = new Person(); // object(Person)#1 (3) { ["name"]=> NULL ["age"]=> NULL ["sex"]=> NULL }    $person2 = new Person(); // object(Person)#2 (3) { ["name"]=> NULL ["age"]=> NULL ["sex"]=> NULL }    /**     * 資源     * ok.txt需要放在當前php所在目錄下     * 如果文本中的內容是中文編碼格式請使用UTF-8     * 在txt另存的時候可以看到編碼選項     */    $file = fopen("ok.txt","r"); // 現在顯示的是ok.txt的內容//    if (NULL=="ok.txt"){//        printf("不存在<br>");//    }else{//        printf("存在<br>");//    }    echo $int;    echo "<br>";    echo $str2;    echo "<br>";    echo $str3;    echo "<br>";    echo $str4;    echo "<br>";    echo $str5;    echo "<br>";    echo $str6;    echo "<br>";    //echo $str7;    echo "<br>";    echo $str8;    echo "<br>";    echo $str9;    echo "<br>";    echo $str10;    echo "<br>";    var_dump($arr);    echo "<br>";    var_dump($person);    echo "<br>";    var_dump($person2);    echo "<br>";    echo fread($file,filesize("ok.txt"));    echo "<br>";    fclose($file); // 釋放資源

以上就是Android程式員學PHP開發(6)-字串數組對象資源-PhpStorm 的內容,更多相關內容請關注topic.alibabacloud.com(www.php.cn)!

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.