title: PHP check if contents are available
body: <p>I am using random.org in my php script to generate random numbers like that: </p>
  
  <pre><code>    function getToken($length){
          $r = explode('
  ',file_get_contents('http://www.random.org/integers/?num='.$length.'&amp;min=0&amp;max=9&amp;col=1&amp;base=10&amp;format=plain'));
          $string = '';
          foreach ( $r as $char ) $string.=$char;
          return $string;
      }
  </code></pre>
  
  <p>but my university net denies such queries, so whenewer i test my project using university wifi, i dont get random numbers to be generated, and that means trouble. </p>
  
  <p>So, i before using this function, it needs to be chect if i can query random.org or not like that:</p>
  
  <pre><code>    if( site is accessible ) return getToken();
      else return false;
  </code></pre>
  
  <p>what would be the best way to check accesability? </p>
  
  <p>Myself i tried:</p>
  
  <pre><code>    file_get_contents();
  </code></pre>
  
  <p>but it sends warnings,whenewer it fails,</p>
  
  <pre><code>    dns_get_record();
  </code></pre>
  
  <p>but i dont know if i can trust that, if it checks only dns name. 
  Please help! </p>
  
  <p>P.S. a pinging technique might proove usefull...</p>