Last Updated: February 25, 2016
·
3.017K
· ivanca

Check if is local connection in PHP (by IP comparison)

<?php 

function isLocal(){
  return $_SERVER['SERVER_ADDR'] === $_SERVER['REMOTE_ADDR'];
}

Then you can use it like

$dir = isLocal() ? '/root/' : 'webhosting/data/';