Jump to content

how to open php file then add codes?


t_machine

Recommended Posts

hi, I am creating a script that I would like to open a specific file then seach for a phrase (eg. //add text here) then place new codes there.
I think the script will need to first check if the file is writable and if not, make it writable then open the file and search for the phrase. It should then close the file and return to previous file permission.
Any help on this would be really great. Thanks :)
Link to comment
https://forums.phpfreaks.com/topic/36460-how-to-open-php-file-then-add-codes/
Share on other sites

http://us2.php.net/manual/en/function.file.php

http://us2.php.net/manual/en/function.file-get-contents.php

http://us2.php.net/str_replace


those 3 manual pages should give you exactly what you need. note the differences between file() and file_get_contents()

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.