config database.php file |
[eluser]cinewbie81[/eluser]
Hi guys, IN CI, we need to pre-define database setting in database config file before we can actually use that database. It's rather troublesome especially for those users without the programming background. Thus i was thinking to create a GUI and let the user to type in the database name. From user input, I will then append the content to the database config file automatically. Here's how the database config file looks like: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); My problem now is how can I append the new content just right before the php closing tag '?>'. Any idea ?
[eluser]Chris Newton[/eluser]
You could write this info to a database table. or You could write it to a text file and include it. or You could open this file, and overwrite it with the new data.
[eluser]cinewbie81[/eluser]
Hi, i choose to open this file, and overwrite it with the new data. I found this on some other site: Code: $f="myfile.txt"; this fill append the new data into the 1st line and remove the last line of the file.. In my case i need to append the new data into the 2nd last line of the file (just right before php closing tag '?>' ... how can i do it ?
[eluser]ejangi[/eluser]
Instead of trying to add it before the current ?>, why not just add a new PHP block: Code: $f="myfile.txt";
[eluser]Grahack[/eluser]
I think that you can forget this closing tag, it's even better without it: see Zend coding standards at B.2.1. |
Welcome Guest, Not a member yet? Register Sign In |