下面的资料可以在网站的所有文件加上头尾文件,但是我想要的是在网站的某一目录下加,而不是整个网站.--资料--
我想在每个文件最前,最后面都加上一文件.但一个一个添加很麻烦1:打开php.ini文件
设置 include_path= "c:"2:写两个文件 
auto_prepend_file.php 和 auto_append_file.php 保存在c盘,他们将自动依附在每个php文件的头部和尾部.3:在php.ini中找到:
Automatically add files before or after any PHP document.
auto_prepend_file = auto_prepend_file.php;依附在头部
auto_append_file = auto_append_file.php;依附在尾部以后你每个php文件就相当于PHP:--------------------------------------------------------------------------------<?php 
Include "auto_prepend_file.php" ;.......//这里是你的程序
Include "auto_append_file.php";
?>--------------------------------------------------------------------------------

解决方案 »

  1.   

    <?php
    $str = "include();";   //要添加的内容
    $dir = "test"; //要更新的目录
    updir($dir,$str);function updir($dir,$str)

    $handle = @opendir($dir);
    while (false !== @($file = readdir($handle))) 

    if ($file != "." && $file != "..") 

    if (is_file("$dir/$file"))

    echo "<p>$dir/$file";
    $path_parts = pathinfo("$dir/$file");
    if ($path_parts["extension"]=="php")
    $fp = @fopen("$dir/$file",'r+');
    @fwrite($fp, $str);
    @fclose($fp);
    //最好加上替换<?
    }
    else
        updir("$dir/$file",$str);
    }
    }
    closedir($handle); 
    }
    ?>
      

  2.   

    <?php
    $str = "include();";   //要添加的内容
    $dir = "test"; //要更新的目录
    updir($dir,$str);function updir($dir,$str)

    $handle = @opendir($dir);
    while (false !== @($file = readdir($handle))) 

    if ($file != "." && $file != "..") 

    if (is_file("$dir/$file"))

    echo "<p>$dir/$file";
    $path_parts = pathinfo("$dir/$file");
    if ($path_parts["extension"]=="php")
    $fp = @fopen("$dir/$file",'r+');
    $data = @fread($fp,"$dir/$file");
    $str.=$data;
    @fwrite($fp, $str);
    @fclose($fp);
    //最好加上替换<?
    }
    else
        updir("$dir/$file",$str);
    }
    }
    closedir($handle); 
    }
    ?>
      

  3.   

    建议看一下IBF的论坛源程序,他的原理是所有的PHP程序都通过index.php包含进来执行的,这样你想加什么东西,只要在index.php的前面,后面加就好啦,你只要看看一下INDEX.PHP就行啦
      

  4.   

    这有两种做法,一种是直接更改该目录的所有HTML文件,另一种是用PHP来输出,不知你想用那一种
      

  5.   

    建议看一下IBF的论坛源程序,他的原理是所有的PHP程序都通过index.php包含进来执行的,这样你想加什么东西,只要在index.php的前面,后面加就好啦,你只要看看一下INDEX.PHP就行啦
      

  6.   

    用auto_append_file只能全部目录都加上啊