inject php code into html file

i have alot of html file need to edit , only insert <?php include "header.php";?> in every html file, this file in my_html folder , is there any quick way to do that , than open every file just for doing that . administrator not allow using mod_layout .

thanks in advance
Who is Participating?
Multifile text editors like UltraEdit often also support search and replace through multiple files. The files which can be searched thru are either opened, or located in a directory. Possibly the tool you are already using also supports this kind of s&r.

Sorry to drop in, but I thought this would help elaborate:

The way I usually do this type of replace is to ask my editor to search and replace through every file in my directory. I use DWMX2004, but as Roonaan mentioned, any multi-file editor will do.

Assuming I want header.php to be included as the first line after the <body> opening tag in every page:

I would search for:

... and replace with:

<?php include "header.php"; ?>'

Don't need to give me any points, but this may not have been as obvious as it seems.
You can also use sed/perl to do this, eh?
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

hendri2Author Commented:
can u gave me sed/perl code for that
you could also do it in php (this function doesn't check to see if the line is already there):
be very careful with this.

$directory = "c:/myphp/"
echo '<TABLE>';
echo '<TR>';
if($dir_handle = @opendir($directory)) {  //I know @ code is a bad idea, but here I don't see a way of circumventing it
    while($file = readdir($dir_handle))
      if($file !== "." && $file !== ".."){
          if (($count % 4) == 0) { echo '<TR style="width:100%;height:104px;padding-left:10px">'; }
            echo '<TD>';
                $myfile = file_get_contents($file);
                $myfile = '<?php include "header.php"; ?>' . $myfile;
               echo '</TD>' . "\n";

Use Extended Search & Replace in Macromedia Homesite.

search for <html>

replace with <?include "header.php"?> <html>

Find where : In Folder (direct to your folder where all the files exits)
File Type : *.html (or whatever you like)

Pressing Replace button will do the rest.

Now your life become very very easy.

Hope this help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.