将这段程序保存为xxx.php
在HTML主页的某个地方,
<?php
echo file_getc_contents("xxx.php");
?>

解决方案 »

  1.   

    把你这段代码写到一个单独的PHP文件
    然后最后句这样改下
    echo "document.write('\t", $total, "\n');";在你的HTML页面要显示的地方这样引用你的那个PHP页
    <script type="text/javascript" src="myecho.php"></script>
      

  2.   

    <?php
    function getTxt(){
    $filter = '620107';
    $handle = fopen("today_6201.xd", "r");
    $total = 0;
    if ($handle) {
        while (!feof($handle)) {
            $argn = fgets($handle, 4096);
            $p = explode("|", trim($argn));
            if (empty($filter) || $p[0] == $filter) {
                $total += $p[5] > 0 ? $p[8] : (0 + $p[8]);
            }
        }
        fclose($handle);
    }
    return $total;
    }?> 
    写个成函数形式吧,在你要插入的位置直接
    <?PHP echo getTxt();?>
      

  3.   

    照楼上的做了不行啊!!!!!郁闷急急急!!!求知道的解决下!!!!!这段PHP运行结果是个数字!!我要把这个数字直接显示到主页的一个表中!!!!!!
      

  4.   

    <?php 
    function getTxt(){ 
    $filter = '620107'; 
    $handle = fopen("today_6201.xd", "r"); 
    $total = 0; 
    if ($handle) { 
        while (!feof($handle)) { 
            $argn = fgets($handle, 4096); 
            $p = explode("|", trim($argn)); 
            if (empty($filter) || $p[0] == $filter) { 
                $total += $p[5] > 0 ? $p[8] : (0 + $p[8]); 
            } 
        } 
        fclose($handle); 

    return $total; 
    } ?> 
    这样写连正常显示都没有了!!
      

  5.   

    静态页面上用不来php代码的
    你可以先写好放在一个aa.php页面
    在通过<iframe 
    或脚本调用
      

  6.   

     php代码和HTML可以混合在一起;要实现你所说的要求,可以这样做
    <html>
    <head></head>
    <body>
    <?php 
    $filter = '620107'; 
    $handle = fopen("today_6201.xd", "r"); 
    $total = 0; 
    if ($handle) { 
        while (!feof($handle)) { 
            $argn = fgets($handle, 4096); 
            $p = explode("|", trim($argn)); 
            if (empty($filter) || $p[0] == $filter) { 
                $total += $p[5] > 0 ? $p[8] : (0 + $p[8]); 
            } 
        } 
        fclose($handle); 

    ?>
    <p><?php echo $total; ?></p>
    </body>
    </html>