config option that's visible to PHP?

I have a staging server and a live server, and I run the same code base on both... there's some directives in the PHP to change paths, etc, if it's running on staging. But for that to work, the PHP Script has to be able to ID the machine it's on. (I prefer this to setting a flag every time I want to move the code from staging to live.)

I tried using  "if(stristr($_SERVER['HTTP_HOST'], 'localhost'))" which works (since my local apache that I use for testing is just http://localhost)... except I run it on a couple of different staging servers that both resolve as localhost.

Is there some minor Apache option I could set, that would be retrievable in PHP?

(I say minor, since I could probably change 'localhost' to something more machine-specific, but I'd prefer not to. Ideally, it'd be some kind of minor PHP flag I could set in the httpd.conf file, then PHP could just check that.)


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

> it'd be some kind of minor PHP flag I could set in the httpd.conf file, then PHP could just check that.

You might set an apache ENV

SetEnv local 1

should make the ENV 'local' available containing the value 1
how about using $_SERVER['SERVER_NAME'] or $_SERVER['SERVER_ADDR']
pnoericAuthor Commented:
unfortunately, the 'SetEnv' didn't work-- I added it but it never showed up in phpinfo() or $_ENV or $_SERVER.

I ended up using $_ENV['computername'].

Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

pnoericAuthor Commented:
(this question can be closed, with no answer)
> I ended up using $_ENV['computername'].
what doies this mean? Apache has no environment variable computername
pnoericAuthor Commented:
hmm, it showed up in my apache config-- you know, it might be because I'm using this on my local environment, which is a windows pc. it's fine if my staging and dev servers (both linux) don't have computername, since the test will just fall through.
PAQed with points refunded (125)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.