Editing PHP using PHP (admin center)

Posted by Alec Smart on Stack Overflow See other posts from Stack Overflow or by Alec Smart
Published on 2010-06-01T06:39:41Z Indexed on 2010/06/01 6:43 UTC
Read the original article Hit count: 146

Filed under:

Hello,

Am developing an admin center where I can edit configuration files (written in PHP). I do NOT want to store these values in a mySQL table (for various reasons). So say my config.php has contents like:

   <?php
     $option1 = 1;
     $option2 = 2;
     $option4 = 5;
     $option7 = array('test','a','b',c');
   ?>

Now say in one of the admin pages I will only be changing a few values like option2 or option4 etc. Any ideas on what would be the best way to go about this.

I know one option is to read the PHP file completely and write parts of it using REGEX. Any way to make this more efficent? I don't want the config.php file to break because of some error on the user's end. Any ideas on how to ensure that it works?

© Stack Overflow or respective owner

Related posts about php