Is there a way to set a custom variable from within .htaccess
so that every php script can then read from it ? I went googling around nothing.
Thankyou!
You can only set an environment variable from .htaccess:
SetEnv MYVAR whatever
And this becomes available in the $_SERVER
array:
print $_SERVER["MYVAR"];
So, not exactly a global variable. But still useful for some purposes.
(The other option is declaring an auto_prepend_file
to pre-define variables. But that's more a workaround then.)
You can set environment variables in .htaccess
(or http.conf
):
SetEnv foo bar
and access them in PHP via
$_ENV['foo']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With