url_exists

Description

Checks to make sure a URL is valid and that it returns a standard (HTTP 200) status code.

Syntax

bool url_exists (string $url)



Parameter $url

Expected type: String
Description: The URL to check



Return value

Expected type: Boolean
Description: True if the URL is valid and returns a 200 status code, false otherwise


Notes

  • Will return false if the status code is anything other than 200.
  • Will not work if fsockopen() is disabled
  • Parses the URL with parse_url first to ensure proper connection
Advertisement: