Page 1 of 1

using linux commands within php

Posted: Mon Aug 18, 2003 4:15 pm
by mccommunity
I need to write to a template file (tmpfile) but I need to write my contents to the begining of the file. When I use fwrite it writes the new contents to the end of the file and I need to write this to the begining of the template file. I was thinking of writing the new info to a newfile (newfile) and using the linux command cat to do something like cat newfile tmpfile > completefile and complete file being my new file that has the contents at the front. I am not sure how to do this with php though. How do I use linux commands within php? Thanks.

Posted: Mon Aug 18, 2003 4:29 pm
by jason

Code: Select all

$buff = file_get_contents($filename);
$buff = $newStuff.$buff;
$fh = fopen($filename, 'w+');
fwrite($fh, $buff);
fclose($fh);
lalala