Posted By

jackoder on 05/06/10


Tagged

php check server status Information


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

dantreacy
eval
stamba
o0110o


Check Server Status with PHP


 / Published in: PHP
 

Hello Php Coders,

Here's a useful php code block for your projects to control server status.

Use this code blokc to report a server status result. I hope you'll like it. Also; i suggest you to rest for a while on 2 Ki┼čilik Oyunlar and Oyunlar sites to fun. I think you'll like them. I wish you success on your profect and i hope everything'll be best for us. Best codings!

  1. <?
  2.  
  3. # Domain Name
  4. $domainName = "http://www.snipplr.com" ;
  5.  
  6. function DomainCheck($domainName){
  7. $startTime = microtime(true);
  8. $openDomain = fsockopen ($domainName, 80, $errno, $errstr, 10);
  9. $finishTime = microtime(true);
  10. $serverStatus = 0;
  11.  
  12. if (!$openDomain) $serverStatus = -1;
  13. else {
  14. fclose($openDomain);
  15. $status = ($finishTime - $startTime) * 1000;
  16. $serverStatus = floor($serverStatus);
  17. }
  18. return $serverStatus;
  19. }
  20.  
  21. $serverStatus = DomainCheck($domainName);
  22.  
  23. # Print
  24. if ($serverStatus != -1) {
  25. echo "Cannot reach the server!" ;
  26. } else {
  27. echo "Server's running well." ;
  28. }
  29.  
  30. ?>

Report this snippet  

You need to login to post a comment.