第五章. 語法

目 錄
PHP3的寫法 Escaping from HTML
變數的型態
變數的初始化
變數的範圍
變數的變數
PHP外的變數
資料型態的小把戲
陣列

PHP 的語法和 C, JAVA, Perl, 相類似. 每個敘 述以分號";"來分開.

PHP3 的寫法

PHP3 是和 html 文件寫在同一個檔案里面的, 有三種寫法可以用來區分 html 模式和 PHP 模式 :

Example 5-1. Ways of escaping from HTML


1.  <? echo("this is the simplest, an SGML processing instruction\n"); ?>

2.  <?php echo("if you want to serve XML documents, do like this\n"); ?>

3.  <script language="php"> 
        echo ("some editors (like FrontPage) don't
               like processing instructions");
    </script>;

4.  <% echo("As of PHP 3.0.4 you may optionally use ASP-style tags"); %>