title: Bug in my php code which reads data from file and keeps log
body: <p>I'm writing some php code and I want to compare an ip address with the ip address the user is coming from.  This is the code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;?php
  // set date and hour
  $date=date('H:i:s d-m-Y');
  // set ip user
  $ip=$_SERVER['REMOTE_ADDR'];
  // log text
  $ipLog="User entered at " . $date . " from ip address: " . $ip . ".\n";
  // write log
  $firstLogFile="../../logs/firstLogIP.txt";
  // ipcheck
  $myfile=fopen("../../logs/ownip.txt", "r") or die("Unable to read ownip file!");
  $ownip=fgets($myfile);
  fclose($myfile);
  if($ip!=$ownip) {
      $handleFirstLog=fopen($firstLogFile, 'a') or die("&lt;br&gt;&lt;br&gt;Can't open logfile!&lt;br&gt;&lt;br&gt;"); 
      fwrite($handleFirstLog, $ipLog);
      fclose($handleFirstLog);
  }
  ?&gt;
  
  &lt;head&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div class="container"&gt;
          &lt;div class="inner-container"&gt;
          &lt;div&gt;
              &lt;?php           
              if($ip!=$ownip) {
                  print "ips not equal: " . $ip . " " . $ownip;
              } else {
                  print "ips equal";
              }
              ?&gt;
          &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>If the ip address of the user don't equals that of the ip address that's stored in my file (../../logs/ownip.txt) then this should be written to logfile (firstLogIP.txt) and you should see "ips not equal" on the screen.</p>
  
  <p>So if the ip's equal, no log should be written and you should see "ips equal" on the screen.</p>
  
  <p>Althoug my ip address and that of the user ($_SERVER['REMOTE_ADDR']) ARE equal, the script still say's "ips not equal" and the ip address is logged!</p>
  
  <p>Any help with this bug?  Thx!!</p>