"declaring global variable with php.ini" Answer’s


It's not possible to set user-level variables within a plain php.ini file (or the .htaccess equivilents). There are some PECL modules that do allow that, such as hidef (http://pecl.php.net/package/hidef) - though these would need to be installed on every installation you use.

Including (or pre-including) a file with auto_prepend_file is quite possible - though that would be on every PHP request.

What is frequently done is setting an environment variable as part of the webserver process, which can be read from PHP. In Apache this is quite easy, with the SetEnv module.


And accessing it in PHP:

if ($_ENV['PRODUCTION_SERVER']) {...}  // or getenv('PRODUCTION_SERVER')
Wednesday, March 31, 2021
answered 10 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :