NYCPHP Meetup

NYPHP.org

[nycphp-talk] Setting Constants Globally?

Jim Musil jmusil at villagevoice.com
Fri May 9 13:15:48 EDT 2003


This seems to be the best solution, but the problem I have with this is that
you still have a path definition in every file. If for some reason that
location changes, you have to change it in all your scripts.

I'm sure I could search and replace the whole lot of them, but it just
strikes me as messy.

The situation in which it arises the most is when I have a shared set of
development tools that I use on various pages across several different
virtual hosts.

I don't want to do this:

    include("/usr/blah/blah/blah/blah/devtools.php");

I'd rather do this:

    include(DEVTOOLS);  //  DEVTOOLS is defined in one place server wide


Jim



On 5/9/03 12:40 PM, "Malcolm, Gary" <gmalcolm at professionalcredit.com> wrote:

> I have a file with my system wide defines ( define( "THING", defintion); )
> as an include on another file where i put my most common includes (like my
> db classes).
> I then will include the second file to avoid tons of includes in each
> script.
> 
> defines are global within individual scripts.
> 
> works well for me...
> 
> I'm curious how others handle this seemingly common issue.
> 
>> -----Original Message-----
>> From: Jim Musil [mailto:jmusil at villagevoice.com]
>> Sent: Friday, 09 May, 2003 9:34 AM
>> To: NYPHP Talk
>> Subject: [nycphp-talk] Setting Constants Globally?
>> 
>> 
>> 
>> 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