Last Updated: February 25, 2016
·
2.979K
· 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/';