You can use a PHP auto_prepend_file
script in your PHP ini to do this as it will be run before any of your user-land scripts:
Specifies the name of a file that is automatically parsed before the
main file. The file is included as if it was called with the require
function, so include_path is used.
So you can add an ini line like:
auto_prepend_file="/home/user/script.php"
The in /home/user/script.php:
define('CONSTANT_NAME', 'your nice value here');
Now in your PHP scripts you can access CONSTANT_NAME
from wherever you like as it is available in all PHP scripts.
I use this technique on my staging server that uses mod_rewrite based mass virtual hosting so I can give my PHP scripts an accurate document root. I have discussed this in a blog post before.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…