Advertisement
km654

valid url

Mar 21st, 2022
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. function valid_url($url) {
  2.     $resURL = curl_init();
  3.     curl_setopt($resURL, CURLOPT_NOBODY, true);
  4.     curl_setopt($resURL, CURLOPT_URL, $url);
  5.     curl_setopt($resURL, CURLOPT_BINARYTRANSFER, 1);
  6.     curl_setopt($resURL, CURLOPT_HEADERFUNCTION, 'header_callback');
  7.     curl_setopt($resURL, CURLOPT_FAILONERROR, 1);
  8.     curl_setopt($resURL, CURLOPT_HEADER, false);
  9.     curl_exec($resURL);
  10.     $intReturnCode = curl_getinfo($resURL, CURLINFO_HTTP_CODE);
  11.     curl_close($resURL);
  12.     if ($intReturnCode != 200) {
  13.         return 0;
  14.     } else return 1;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement