// 追加內容
$file = fopen(dirname(dirname(__FILE__)).'/index.htm', 'r');
$content = fread($file, filesize(dirname( dirname(__FILE__)).'/index.htm'));
$hello = ' ' . PHP_EOL . $content;
fclose($file);
$file = fopen(dirname(dirname(__FILE__)).'/index.htm', 'w');
echo fwrite( $file, $hello);
fclose($file);
現在上述程式碼是在html的第一行加了,請問,如果
結尾的前面追加怎麼實現呢?謝謝
把html檔案後綴改成.php,直接在頁面所需的位置上加入原來php程式碼就行了