Solved

How to create a server variable in PHP or Apache2

Posted on 2008-06-26
5
300 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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

691 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