• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

How to create a server variable in PHP or Apache2

I want to create a server variable accessable by doing a $_SERVER["xxx"] request or something similar. This variable must be available to all sites residing on the server, so i figured it needs to be set either somewhere in PHP or Apache, so that I can access it from any virtual host residing on the server. How can I do this?
0
Kobz46
Asked:
Kobz46
  • 3
1 Solution
 
hernst42Commented:
Need to be done in apache. See http://httpd.apache.org/docs/2.2/mod/mod_env.html
0
 
Rob SiklosCommented:
There are a few options.  The best one for you depends on how you want to use that variable - specifically, how often (and where) you want to set/change the value.

Have you considered using an environment variable?  You can access them in PHP using $_ENV
0
 
Kobz46Author Commented:
Do i need to add this to the mod_env source and recompile? How do I go about doing this?
0
 
Kobz46Author Commented:
Rob, that might be an option. I'll give it a quick go.
0
 
Kobz46Author Commented:
Great! Added in envvars and works as expected. Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now