Click to See Complete Forum and Search --> : Program that inserts comments to multiple pages


glitchgirl
02-22-2007, 08:14 PM
Hi,

I've searched, but I'm not sure what to 'google'. Is there a program out there, that will allow me to select a directory or group of files and add comments at the top of the php files, obviously after the <?php or adding it between <?php ?>, whatever, at the top of the page haha.

For example:

<?php
##############################################
## Whatever by Whatever ##
## Copyright 2007. All Rights Reserved. ##
##############################################
?>

I finished my php applicatin and realized after 300 pages of code, that I was forgetting to my program comments at the top of the pages .. :(

Thanks,
Jesi

NightShift58
02-22-2007, 09:23 PM
Use glob() to get a list of files in a directory.

Use file_get_contents() to read the content of the files into a ariable

Then, rather than look for a space between a possibly non-existent <?php ?> pair, just prepend<?php
##############################################
## Whatever by Whatever ##
## Copyright 2007. All Rights Reserved. ##
##############################################
?> to the variable.

Finally, with fopen()/fwrite(), write the file back to disk.