1

Each server (Dev, QA, Prod) has a different IP address and URL. I would like to write code so that it can pull that information (the URL for the particular server I am running the code on) from a configuration file and store it in a variable.

Preferably I would like to avoid having to read the information from a file on subsequent requests since the information should not be changing often.

What is the best way to accomplish this?

1 Answer 1

3

Use the $_SERVER array to get the current server details

http://php.net/manual/en/reserved.variables.server.php

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

1 Comment

Specifically, $_SERVER['SERVER_ADDR'] and $_SERVER['SERVER_NAME'] (IP + hostname of the host/virtual host the script's running in).

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.