using linux commands within php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mccommunity
Forum Commoner
Posts: 62
Joined: Mon Oct 07, 2002 8:55 am

using linux commands within php

Post 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.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Code: Select all

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