Solved

How to create a server variable in PHP or Apache2

Posted on 2008-06-26
5
299 Views
Last Modified: 2013-12-12
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
Comment
Question by:Kobz46
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 21875219
Need to be done in apache. See http://httpd.apache.org/docs/2.2/mod/mod_env.html
0
 
LVL 9

Accepted Solution

by:
Rob Siklos earned 500 total points
ID: 21875239
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
 

Author Comment

by:Kobz46
ID: 21875294
Do i need to add this to the mod_env source and recompile? How do I go about doing this?
0
 

Author Comment

by:Kobz46
ID: 21875318
Rob, that might be an option. I'll give it a quick go.
0
 

Author Comment

by:Kobz46
ID: 21875373
Great! Added in envvars and works as expected. Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question