Solved

How to create a server variable in PHP or Apache2

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
$_SERVER Variable question 31 49
php error 27 55
PHP $_POST vs asp request 4 19
Get data from two MySQL tables 6 18
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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

685 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