Last Updated: February 25, 2016
·
646
· 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();
}

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#php
#http
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside