You can auto-prepend a file to all PHP scripts as they are called, in
which you could store some application-wide variables like database
usernames and passwords, config irectives, etc, BUT it's important to
note that this file is loaded into PHP on every call basically as an
include, and each instance of the script being called is separate to
the others, and the PHP application remains stateless.
Since you used the word DEFINE in your post, my guess is this would be
sufficient. However, if you need something with state, or something
more dynamic, then this may not be enough.
FWIW, auto-prepended files can also include logic, database queries,
include other files, or anything else that you can do with an include
file... so it's not just a list of variables -- it's a PHP script.
You can set the php.ini directive auto_prepend_file to the full path of
the file at a server level (eg a dedicated server), or at a directory
level using a .htaccess file, with something like:
---
IfModule mod_php4.c
php_value auto_prepend_file '/path/to/file.php'
/IfModule
---
Or you can do it the old-fashioned-way at script level with
? include('path/to/file.php'); ?
If you want your scripts to be as portable as possible, the last option
is fail-safe. Option requires you to basically be the sys admin of
your server, and option 2 requires your sysadmin to allow .htaccess
files with tweaking of PHP (quite common, but not always).
Justin French
On Sunday, February 8, 2004, at 09:54 PM, Lloyd Bayley wrote:
Greetings Everyone,
I am still new to PHP but am progressing nicely. I has helped a lot
that I have had vast experience with ColdFusion (sorry) but have seen
the light and am now doing rather nicely in PHP.
My question is as follows...
I have certain functions, variables etc that I would like to be active
in an application-wide state.
CF has an application.cfm file that is read in (if it exists in the
directory) which is used for this purpose.
Is there a similar creature in PHP? If not, how is it best to define
application-level stuff?
Many Thanks In Advance,
Lloyd. :-)
--
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