Add variable to $ _SERVER array via php.ini

I need to add a variable to the $ _SERVER array in php script. Is there any way to do this through the php.ini file? I want to add a variable for all scripts on a web server, so it is inconvenient to add it to each script.

Thanks TSS

+6
source share
3 answers

If you are using Apache, try the SetEnv module.

(here you can see more: Declaring a global variable with php.ini )

+3
source

You can install it in your .htaccess or in apache configuration

<VirtualHost *:80> ... SetEnv PARAM "VALUE" ... </VirtualHost> 

It will be added to the variable $_SERVER['PARAM'].

+6
source

I cannot think of a way to add things to $ _SERVER via php.ini (which does not mean that it has no way to do this).

However, you could add things to $ _ENV on the server using SetEnv in httpd.conf (assuming apache here). There are likely methods for doing this with other web servers, but I'm not sure what it is.

+2
source

Source: https://habr.com/ru/post/892654/


All Articles