前面不还有 <?php 吗?你怎么没看见

解决方案 »

  1.   

    我想问,这个函数直接引用为什么就可以直接输出HTML啊
      

  2.   

    ?> 表示 php 语言代码段结束,html 语言代码段开始
    <?php 表示 html 语言代码段结束,php 语言代码段开始
    你断章取义的看,自然就糊涂了
      

  3.   

    嗯嗯,多谢!
    请问这样通过调用do_html_header($header)这个函数来输出HTML合适吗
      

  4.   

    html與php代碼混合寫在php function 中不推薦。可以把html代碼換成用php echo 輸出更好。
      

  5.   

    这就是混合编写啊,不过文件要用php来解释
      

  6.   

    楼主看代码要仔细。
    function do_html_header($title) {
      // print an HTML header
    ?>

      <html>
      <head>
        <title><?php echo $title;?></title>
        <style>
          body { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
          li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
          hr { color: #3333cc; width=300; text-align=left}
          a { color: #000000 }
        </style>
      </head>
      <body>
      <img src="book.gif" alt="PHPbook logo" border="0"
           align="left" valign="bottom" height="55" width="57" />
      <h1>PHPbook</h1>
      <hr />
    <?php
      if($title) {
        do_html_heading($title);
      }
    }
      

  7.   

    上面那个发错了function do_html_header($title) {
      // print an HTML header
    ?>

      <html>
      <head>
        <title><?php echo $title;?></title>
        <style>
          body { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
          li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
          hr { color: #3333cc; width=300; text-align=left}
          a { color: #000000 }
        </style>
      </head>
      <body>
      <img src="book.gif" alt="PHPbook logo" border="0"
           align="left" valign="bottom" height="55" width="57" />
      <h1>PHPbook</h1>
      <hr />
    <?php
      if($title) {
        do_html_heading($title);
      }
    }
      

  8.   

    有结束,必定又开始,有一个?>,必有一个<?php,,一一对应。。我就是这么记得。。