Hi,
No matter the size of a project using includes and config files are always a
good way to go.
In the include file I would (as it states) include all main files that are
common for all pages. Such as a DB class (if common), template classes, etc.
In the config file (or you can call it define file) I would define all
constants that might be used. Such as:
define("ROOTDIR", "/wherever/your/webroot/is");
define("CLASSDIR", ROOTDIR . "/classes"); //not the best way, I usually keep
my classes out of the webroot
define("DB_HOST", "localhost");
Or you can have a txt config file config.cfg
ROOTDIR /wherever/your/webroot/is
CLASSDIR [ROOTDIR]/classes
And then you just have to read and parse that with a general define script
:) Something like this (don't have the code here, so I try it anyways).
<?php
$configcontent = file_get_contents("config.cfg");
$lines = explode("\n", $configcontent);
foreach($lines AS $line) {
$line = trim($line);
if(preg_match("/^[A-Z_]+\s+.+$/", $line)) {
$linemodified =
preg_replace("/^([A-Z_]+)\s+(.+)$/","$1:$2",$line);
list($const, $value) = explode(":", $linemodified, 2);
define($const, $value);
}
}
?>
Best regards,
Peter Lauri
www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free
-----Original Message-----
From: Mike Shanley [mailto:[EMAIL PROTECTED]
Sent: Saturday, February 17, 2007 5:06 AM
To: [email protected]
Subject: [PHP] Quick organizational question...
Hi!
Question:
For a website that will have a database driven store, articles, an rss
feed, and a few other things... not an enormous site, but one with
growth potential, does it makes sense to organize the whole thing as
includes through a single main page? It seems like a fun way to do
things, but I was just wondering what you all thought.
BTW- It's my first time here! Hello world!
--
Mike Shanley
~you are almost there~
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php