Test whether URL exists


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function url_exists($url) {
  2. $hdrs = @get_headers($url);
  3. return is_array($hdrs) ? preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/',$hdrs[0]) : false;
  4. }

URL: http://us2.php.net/manual/en/function.file-exists.php#84918

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.