title: Will PHP's gethostname and gethostbyname always work?
body: <p>I'm developing a PHP app which needs to be locked down to a particular server IP address so that people cannot easily copy it to other servers. The application will be installed on an internal server at the client's office. </p>
  
  <p>I have an encoded license file with the allowed server IP address stored in it, and on the login page I want to check that this matches the IP of the server.</p>
  
  <p>To do this I use the following code:</p>
  
  <pre><code>if(getHostByName(getHostName()) != $licensedServerIp){
    throw new Exception("The server's IP address does not match that in your license file.");
  }
  </code></pre>
  
  <p>This works nicely on my development machine, but are there any situations that I need to look out for where this function would fail? I have no idea what the function is actually doing in the background - could certain network issues stop this from working?</p>