菜单
  
    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. 酸性水汽提装置总汽提塔设计+CAD图纸

  11. 中考体育项目与体育教学合理结合的研究

  12. 十二层带中心支撑钢结构...

  13. java+mysql车辆管理系统的设计+源代码

  14. 大众媒体对公共政策制定的影响

  15. 当代大学生慈善意识研究+文献综述

  16. 乳业同业并购式全产业链...

  17. 杂拟谷盗体内共生菌沃尔...

  

About

751论文网手机版...

主页:http://www.751com.cn

关闭返回