Solved

How to create a server variable in PHP or Apache2

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

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). #…
This article discusses how to create an extensible mechanism for linked drop downs.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

912 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

22 Experts available now in Live!

Get 1:1 Help Now