2

I have set environment variable in:

  1. System (Windows 7, apache)

    ENVIRONMENT = localhost
    
  2. .htaccess file

    SetEnv ENVIRONMENT localhost
    

Now in my php code I get this variable with function getenv().

$environment = getenv('ENVIRONMENT'); 

Question:

How to get variable from system first, if it is not set, then get variable from .htaccess

2
  • 1
    “This house originally had a red door, but now it has been replaced with a blue one – so how can I now take a photo of it that still shows the old red door?” – you can’t, of course. Commented Dec 4, 2015 at 12:48
  • SetEnv is actually the same thing as setting a system env var. The difference is that you set it with a specific value that only applies to the environment in which apache runs. You can define the ENVIRONMENT variable with any value you like, as long as apache is running in a different environment, it doesn't matter. So when you say "get the var from system", you seem to mean "get it from env X first, then from the apache env" which makes no sense at all Commented Dec 4, 2015 at 12:53

1 Answer 1

1

As i know you can't htaccess overwriting all, only the option is take that ENVIRONMENT var in other php script where that htaccess not have any influence and store it in session lets say and the overwrite by session(if it presetn) $environment variable

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.