Advertisement
Googleinurl

[SCRIPT]=> Capturar dados servidor remoto

Jul 18th, 2014
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2.  
  3. function getHttpResponseCode($url) {
  4.     $ch = curl_init();
  5.     curl_setopt($ch, CURLOPT_URL, $url);
  6.     curl_setopt($ch, CURLOPT_HEADER, TRUE);
  7.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
  8.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  9.     $status = null;
  10.     $response = curl_exec($ch);
  11.     preg_match_all('(HTTP.*)', $response, $status['http']);
  12.     preg_match_all('(Server:.*)', $response, $status['server']);
  13.     preg_match_all('(X-Powered-By:.*)', $response, $status['X-Powered-By']);
  14.     return $status;
  15. }
  16.  
  17. $x = (getHttpResponseCode("http://google.com.br"));
  18.  
  19. print_r($x['http'][0][0]);
  20. print_r($x['server'][0][0]);
  21. print_r($x['X-Powered-By'][0][0]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement