菜单
  
    PHP Star t and End Tags The PHP parser recognizes a few types of PHP start and end tags. It will attempt to execute anything between these tags, so it had better be valid code!
    Study Table 4.1 to learn the three main sets of start and end tags recognized by the PHP parser.37249
     
    Next, you'll use all three sets of tags in a script, which I promise will execute without errors.
    1. Open a new file in your text editor.
    2. Type the following code, which uses the first tag type:

        <?php
         echo "<P>This is a test using the first tag type.</P>";
         ?>

    3. Type the following code, which uses the second tag type:
    4.
        <?
        echo "<P>This is a test using the second tag type.</P>";
        ?>

    4. Type the following code, which uses the third tag type:
        <script language="php">
        echo "<P>This is a test using the third tag type.</P>";
        </script>
    Table 4.1: Basic PHP Start and End
    Tags
    Opening Tag Closing Tag

       <?php ?>
       <? ?>
       <script language="php"> </script>
    5. Save the file with the name phptags.php.
    6. Place this file in the document root of your web server.
    7. Open your web browser and type http://127.0.0.1/phptags.php.
     
    In your web browser, you should see the results of your script.
    In the next section, you'll learn that putting PHP blocks inside HTML is not a scary thing.
     
    Code Cohabitation
    Note While executing the examples in this book, if you are using PHP on an external web
    server, substitute that server's domain name for the 127.0.0.1 address in the URL.
    In the previous section, your file consisted of three chunks of PHP code, each of which printed some HTML text. In this section, you'll create a script that has PHP code stuck in the middle of your HTML, and you'll learn how these two types of code can peacefully coexist.
    1. Open a new file in your text editor.
    2. Type the following HTML:
        <HTML>
        <HEAD>
        <TITLE>My First PHP Script</TITLE>
        </HEAD>
        <BODY>
    3. Type the following PHP code:
    <?
    echo "<P><em>Hello World! I'm using PHP!</em></P>";
    ?>
    4. Add some more HTML so that the document is valid:
    </BODY>
    </HTML>
    5. Save the file with the name firstscript.php.
    6. Place this file in the document root of your web server.
    7. Open your web browser and type http://127.0.0.1/fir stscr ipt.php.
    In your web browser, you should see the results of your script.
    In your web browser, view the source of this document.
     
    Notice that the HTML source contains only HTML code, which is correct because this block of PHP was executed:
    <?
    echo "<P><em>Hello World! I'm
    using PHP!</em></P>";
    ?>
     
    This block contains three elements: the command (echo), the string (<P><em>Hello World! I'm using PHP!</em></P>), and the instruction terminator (;).
    Familiarize yourself now with echo, because it will likely be your most often-used command. The echo statement is used to output information—in this case, to print this HTML output:
    <P><em>Hello World! I'm using PHP!</em></P>
    The next section discusses a common error, with the hope that you'll be able to avoid it.
  1. 上一篇:注射成型模具残余应力英文文献和中文翻译
  2. 下一篇:JSP的优点英文文献和中文翻译
  1. 汽车内燃机连杆载荷和应...

  2. 机械手系统英文文献和中文翻译

  3. 固体氧化物燃料电池英文文献和中文翻译

  4. 船舶运动仿真系统英文文献和中文翻译

  5. 新能源空调系统设计英文文献和中文翻译

  6. 正交试验回归法和响应曲...

  7. 机械设计制造及其自动化英文文献和中文翻译

  8. 中国传统元素在游戏角色...

  9. 浅析中国古代宗法制度

  10. 上市公司股权结构对经营绩效的影响研究

  11. 现代简约美式风格在室内家装中的运用

  12. g-C3N4光催化剂的制备和光催化性能研究

  13. C++最短路径算法研究和程序设计

  14. 巴金《激流三部曲》高觉新的悲剧命运

  15. 高警觉工作人群的元情绪...

  16. NFC协议物理层的软件实现+文献综述

  17. 江苏省某高中学生体质现状的调查研究

  

About

优尔论文网手机版...

主页:http://www.youerw.com

关闭返回