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.
上一篇:注射成型模具残余应力英文文献和中文翻译
下一篇:JSP的优点英文文献和中文翻译

AngularJS技术介绍英文文献和中文翻译

开关电源水冷却系统英文文献和中文翻译

减数分裂和基因重组英文文献和中文翻译

太阳能最大功率点追踪和...

移动码头的泊位分配问题英文文献和中文翻译

虚拟船舶装配集成建模方...

中学生科学探究中对等论...

压疮高危人群的标准化中...

酵母菌发酵生产天然香料...

浅谈高校行政管理人员的...

从政策角度谈黑龙江對俄...

STC89C52单片机NRF24L01的无线病房呼叫系统设计

上海居民的社会参与研究

基于Joomla平台的计算机学院网站设计与开发

浅论职工思想政治工作茬...

提高教育质量,构建大學生...

AES算法GPU协处理下分组加...