-
Nov 15th, 2012, 04:03 PM
#1
Thread Starter
Lively Member
Config files
So, I need config.php file
like $settings['home'] = 'http://mysite.com';
and include it in index.php so I can use it on the links like that <a href="'.$_settings['home'].'">Home</a>
how I do the including? thanks!
didn't find any help from google
Last edited by vmen; Nov 15th, 2012 at 04:07 PM.
-
Nov 15th, 2012, 04:11 PM
#2
Re: Config files
when in doubt, go to the source... http://www.php.net ....
include_once() function
-tg
-
Nov 15th, 2012, 04:19 PM
#3
Thread Starter
Lively Member
Re: Config files
how to use the $settings['home'] on a link?
-
Nov 15th, 2012, 04:32 PM
#4
Re: Config files
just like you would any other variable... that's all it is .... an array called $settings ... and in it is an element named 'home' .... so you can echo it, concatenate it, what ever you need to just like anything else... there's nothing magical or special about it.
-tg
-
Nov 15th, 2012, 05:05 PM
#5
Thread Starter
Lively Member
Re: Config files
Ok, now how to make a page where I can edit these settings?
-
Nov 15th, 2012, 09:51 PM
#6
Re: Config files
If you wish to make the settings editable via Admin panel or something, then for the config.php file, include only the db credentials. Like, dbname, dbuser, dbpassword, dbhost, etc. And keep the rest of the settings inside a table in the database. This would make the editing and fetching pretty easier.
And when each page loads, first issue a SELECT query to the db to fetch the others settings that would be used in your project.
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Nov 15th, 2012, 11:04 PM
#7
Re: Config files
I jsut open the page in notepad, edit, save, upload...
but I also work locally when developing a site, then upload it when its ready...
-tg
-
Nov 15th, 2012, 11:10 PM
#8
Re: Config files
Originally Posted by techgnome
I jsut open the page in notepad, edit, save, upload...
but I also work locally when developing a site, then upload it when its ready...
-tg
Yeah. That's what me too do. But if you wish to allow the user to edit the settings via an Admin Panel made for the project, wouldn't it be better to keep the other settings in the db ? Easy retrieval and updation. Wouldn't it be ? Rather than re-writing the config.php file programmatically!
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Nov 16th, 2012, 08:07 AM
#9
Re: Config files
If that's the case, sure... but I'm not sure that is the case... the op has been pretty vague... it's probably at this point where I'd turn to the OP and say "Just what is it you're trying to do?"
@OP - Just what is it you're trying to do here? What's the goal? What's the big picture?
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|