久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      三種在php程序中嵌入html代碼的方法

      三種在php程序中嵌入html代碼的方法

      php程序嵌入html代碼的三種方法如下:

      第一種是在HTML中加PHP

      大段大段的html代碼中,在各個(gè)需要執(zhí)行php的地方<?php …. ?>

      比如 line7-9:

       1 <head>  2     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  3     <meta http-equiv="Content-Language" content="zh-CN" />  4     <title>Hello World</title>  5 </head>  6 <body>  7     <?php  8     echo "Hello world!這是正文";  9     ?> 10 </body> 11 </html>

      第二種用echo輸出HTML。

      因?yàn)镠TML有的元素中有雙引號(hào),所以用echo輸出的內(nèi)容用單引號(hào)括起來(lái),避免出錯(cuò),也省了轉(zhuǎn)義這一步。比如這樣的代碼:

      (學(xué)習(xí)視頻分享:php視頻教程)

        <?php       if(!$_POST){       echo ‘<form action="" method="post">       服務(wù)器地址:<input type="text" name="host" value="localhost" /><br />       數(shù)據(jù)庫(kù)賬號(hào):<input type="text" name="user" value="" /><br />       數(shù)據(jù)庫(kù)密碼:<input type="password" name="pwd" value="" /><br />       指定數(shù)據(jù)庫(kù):<input type="text" name="db" value="test" /><br />       <input type="submit" value="確定"/>       </form>‘;      }  ?>

      或者這種加了轉(zhuǎn)義符號(hào)的:

      <?php      echo "<input type="submit" value="確定"/>" ;  ?>

      第三種就是用(<<<)標(biāo)記符了,這是在PHP168的模板代碼中首次見到的。

        <?php       print <<<EOT       <div class="slidecont">{$label[deepblue_mainslide]}</div>      <div class="newcontainter">           <div class="head">{$label[deepblue_mainh1]}</div>           <div class="cont" id="Tab1">{$label[deepblue_maint1]}</div>           <div class="cont" id="Tab2">{$label[deepblue_maint2]}</div>       </div>       <a href="$rs[url]" title="$rs[descrip]" target="_blank">$rs[name]</a>  EOT;   ?>

      “<<<EOT”和“EOT;”中間的文檔直接輸出,一個(gè)比較好理解的說(shuō)法是“一個(gè)多行的echo ”。
      優(yōu)點(diǎn)是輸出大段HTML方便,不需要轉(zhuǎn)義,而且可以引用變量。

      但是在使用(<<<EOT) 標(biāo)記符還有一點(diǎn)需要注意:標(biāo)識(shí)符結(jié)束字符串既EOT;要獨(dú)占一行,前后都不許再有內(nèi)容,否則這個(gè)php文件就相當(dāng)于廢了。

      這里的EOT標(biāo)記可以替換成 任意標(biāo)記 比如 print <<<END

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)