毕业论文

打赏
当前位置: 毕业论文 > 外文文献翻译 >

PHP和HTML混合英文文献和中文翻译

时间:2019-07-20 16:46来源:毕业论文
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 ta

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. PHP和HTML混合英文文献和中文翻译:http://www.youerw.com/fanyi/lunwen_35973.html
------分隔线----------------------------
推荐内容