NYCPHP Meetup

NYPHP.org

[nycphp-talk] Setting Constants Globally?

Brian Pang bpang at bpang.com
Fri May 9 12:44:00 EDT 2003


something that I do is put this at the top of every page

require_once($_SERVER['DOCUMENT_ROOT'] . "/LIB.php");

with the contents of LIB.php including:

$ROOT = "/path/to/home/dir";
$HTROOT = $_SERVER['DOCUMENT_ROOT'];
$FUNCTIONS = "$HTROOT/FUNCTIONS";
$INCLUDES = "$HTROOT/INCLUDES";

$IMAGES = "$WEBROOT/images";


which I use as global vars...

I also do things like session_start() and other similar global
activities in this file (or files included/required from LIB.php), i.e.
db connections, 


note: make sure that these files don't produce any output or they will
interfere with session/cookie setting



> 
> Hi,
> 
> Pardon me if the answer to this question is obvious, but is there a way to
> define my own constants that are global for all php scripts?
> 
> I see that I could auto_prepend a file to every script, but I'm more
> interested in being able to set my own constant.
> 
> Something like PATH_TO_DEVTOOLS ...
> 
> Maybe there is a better way to do something like this?
> 
> 
> 
> Jim
> 
> 
> 
> 
> --- Unsubscribe at http://nyphp.org/list/ ---
> 
> 
> 
> 






More information about the talk mailing list