三日php之路 -- 第一天(php語言參考)

來源:互聯網
上載者:User

標籤:io   使用   ar   檔案   資料   sp   on   c   代碼   

一、基本文法

    (1)PHP標記

<?phpecho "Hello World!";// 當檔案為純PHP時,最好在末尾刪除PHP結束標記//?>

    (2)從HTML中分離

// 在一對開始和結束之外的內容,都會被PHP解譯器忽略。也就是html標籤和PHP代碼混合的那種,跟jsp,asp一樣...<p>This is going to be ignored by PHP and displayed by the browser.</p><?php echo ‘While this is going to be parsed.‘; ?><p>This will also be ignored by PHP and displayed by the browser.</p>// 使用條件,進階分離<?php if ($expression == true): ?>    This will show if the expression is true.<?php else: ?>    Otherwise this will show.<?php endif; ?>

    (3)指令分隔字元,注釋

        PHP需要在每個語句後面用分隔字元結束指令。

        注釋: // 或 /* ... */  但是,*/ 會匹配最近的那個,切記!切記!

二、類型

    PHP支援8種未經處理資料類型。

    四種標量類型:boolean(布爾型),integer(整型),float(浮點型,double),string(字串)

    兩種複合類型:array(數組),object(對象)

    兩種特殊類型:resource(資源),NULL(無類型)

<?php$a_bool = TRUE;   // a boolean$a_str  = "foo";  // a string$a_str2 = ‘foo‘;  // a string$an_int = 12;     // an integerecho gettype($a_bool); // prints out:  booleanecho gettype($a_str);  // prints out:  string// If this is an integer, increment it by fourif (is_int($an_int)) {    $an_int += 4;}// If $bool is a string, print it out// (does not print out anything)if (is_string($a_bool)) {    echo "String: $a_bool";}?>

    (1)Boolean 布爾類型







三日php之路 -- 第一天(php語言參考)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.