Last Updated: February 25, 2016
·
470
· arosemena

How to detect where the server is running in PHP

An easy way to define where your application is running is to look at the server global array variable , in here you can find all kind of information about the HTTP request

$isLocal = $_SERVER['HTTP_HOST'] == 'localhost';

then you can toggle different behavior like:

if($isLocal) {
    debugApp();
}