Aaron_Escobar Posted May 18, 2009 Share Posted May 18, 2009 Hi everyone, I have a php control panel which I'm going to use to make quick edits to a configuration.php file for my custom content managing php framework. The settings that I want to change with the control panel will be actually changing definitions in the configuration.php file. Definitions like: define("SITE_OWNER", "John Doe"); define("SITE_NAME", "MyDomain.com'); Where do I start? Can I use fopen() to edit specific parts of the php file? Link to comment https://forums.phpfreaks.com/topic/158647-using-php-to-edit-php-can-i-use-fopen-to-edit-specific-parts-of-a-php-file/ Share on other sites More sharing options...
Ken2k7 Posted May 18, 2009 Share Posted May 18, 2009 I would go with: $file = file('filename.php'); file will take your file and store each line into an array. That means $file is an array. Each entry in the array would be a new line. Loop through it and make the necessary changes. After that, just use file_put_contents to write it back into the file. Link to comment https://forums.phpfreaks.com/topic/158647-using-php-to-edit-php-can-i-use-fopen-to-edit-specific-parts-of-a-php-file/#findComment-836691 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.