Check availability URL

Hi! how to write a function that will check the availability of URL http://www.site.com/index.php and return 200 if all is well ? and if the page is not available, then an error code ?
thank you

httpgoogle.png

and https? port 443