2012-04-19 2 views

ответ

0

Потому что ваш вопрос не ясно мне, я только могу помочь вам с этим кусок кода:

<?php 

    echo '<html>'; 
    echo $content; //Contents, where you get these? file_get_contents('file_path_here'); 
    echo '</html>'; 

?> 
0

Ваш вопрос не ясен. В принципе, вы можете сделать это:

$file_name = 'something'; 
$old_content = file_get_contents($file_name); 

$html_before = '<html>... something before the old content'; 
$html_after = '</html>... something after the old content'; 

$result = $html_before . $old_content . $html_after; 

file_put_contents($file_name, $result); // overwrite the original file. make sure you have backup for that. 

Если вы хотите сделать это для всех файлов внутри каталога, вы можете попробовать:

$dir_path = '/path/to/your/dir'; 

$dir = dir($dir_path); 
if ($dir !== false) { 
    while (($item = $dir->read()) !== false) { 
     if ($item == '.' || $item == '..') continue; // skip . and .. 
     $path = $dir->path . '/' . $item; 
     if (is_dir($path)) continue; // skip directory 

     $old_content = file_get_contents($path); 

     $html_before = '<html>... something before the old content'; 
     $html_after = '</html>... something after the old content'; 

     $result = $html_before . $old_content . $html_after; 

     file_put_contents($path, $result); // overwrite the original file! 
    } 
    $dir->close(); 
} 
Смежные вопросы