Solved

How to create a server variable in PHP or Apache2

Posted on 2008-06-26
5
295 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
  • 3
5 Comments
 
LVL 48

Expert Comment

by:hernst42
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Rob, that might be an option. I'll give it a quick go.
0
 

Author Comment

by:Kobz46
Comment Utility
Great! Added in envvars and works as expected. Thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now