Check if PHP is running in local server
<p>Well. I read some topics in SO but I not found a very specific answer. </p>

<p>I need to check with PHP if a PHP code is running in local or remote host. Currently I check with <code>$_SERVER['SERVER_NAME']</code> but it is inconsistent. In this case, if I run PHP with listed IPs like <code>127.0.0.1</code> or <code>localhost</code> it'll consider local, otherwise remote. If I share my IP with a friend, my code still local, but it consider remote because the shared IP isn't listed.</p>

<p>Well, I think that check IP for localhost is not a good idea (except if you know a good method). I tried methods like <code>gethostbyaddr()</code> and <code>gethostbyname()</code> but don't work correctly too.</p>

<p>I don't have a PHP code to show, but my code is basically that:</p>

<pre><code>// true = localhost
return $_SERVER['SERVER_NAME'] === '127.0.0.1';
</code></pre>

<p>The fundamental question is: what can determine that PHP is running local? What is "local" for PHP? I think that it can solve the problem.</p>

<p>Obs.: I don't have access to CMD/Shell with PHP.</p>
