using linux commands within php
Moderator: General Moderators
-
mccommunity
- Forum Commoner
- Posts: 62
- Joined: Mon Oct 07, 2002 8:55 am
using linux commands within php
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.
Code: Select all
$buff = file_get_contents($filename);
$buff = $newStuff.$buff;
$fh = fopen($filename, 'w+');
fwrite($fh, $buff);
fclose($fh);