title: PHP stuck on "waiting for localhost"
body: <p>Before getting into more detail, I just wanted to clarify that I am a pretty fresh, new PHP programmer. I am not even sure if I set it all up correctly to be honest.
  Please bear with me.</p>
  
  <p>I am having troubles with programming a pretty basic IRC Twitch.tv Bot. Whenever I try to open/refresh the page, it gets stuck up on "waiting for localhost", and I've got absolutely no idea why. </p>
  
  <p>I encountered that whenever I remove the loop, it seems to load, and It displays "0 0 resource(2) of type (stream)",
  but from what I've gathered online the loop is essential. </p>
  
  <p>I am running Apache 2.4 and PHP 7.2.12 (cli). Only testing on localhost for now.</p>
  
  <p>Please help, I'm stumped.</p>
  
  <pre><code>&lt;?php
  
  set_time_limit(0);
  
  // info hidden for privacy reasons
  $channel = "#channelname";
  $server = "irc.chat.twitch.tv";
  $port = 6667;
  $nick = "botsname";
  $pass = "oauth:xxxxxxxxx";
  
  $socket = fsockopen($server, $port, $errno, $errstr, 15);
  echo $errno." ".$errstr;
  
  fputs($socket,"PASS ".$pass."\r\n");
  fputs($socket,"NICK ".$nick."\r\n");
  
  echo var_dump($socket);
  
  fputs($socket,"JOIN ".$channel."\r\n");
  
  while(1) {
  
      while($data = fgets($socket, 256)) {
  
          echo nl2br($data);
          flush();
  
          $ex = explode(' ', $data);
          if($ex[0] == "PING") 
          {
              fputs($socket, "PONG ".$ex[1]."\r\n");
          }
      }
  
  }
  
  ?&gt;
  </code></pre>