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
Printable View
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
when in doubt, go to the source... http://www.php.net ....
include_once() function
-tg
how to use the $settings['home'] on a link?
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
Ok, now how to make a page where I can edit these settings?
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.
:wave:
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!
:wave:
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