I want to determine whether a website can be opened. use the phpping website to check whether ping is successful. 2. whether the http return is 200Ok3. is there any html tag in the file content? I don't know how to implement it in step 3. I just want to use file_get_content and find out if there is any html in the file ?... I want to determine whether a website can be opened
1. ping the website using php to check whether the website can be pinged.
2. whether the http return result is 200Ok
3. whether the file content contains html tags
At present, I don't know how to implement the third step. it's file_get_content. then I can find out if there is any html in this file?
Use strpos?
Reply content:
I want to determine whether a website can be opened
1. ping the website using php to check whether the website can be pinged.
2. whether the http return result is 200Ok
3. whether the file content contains html tags
At present, I don't know how to implement the third step. it's file_get_content. then I can find out if there is any html in this file?
Use strpos?
If a jump like 302 is counted as successful access, you can add it to the judgment.
If ($ curl_code = 200 | $ curl_code = 302) {echo 'connection successful, status code :'. $ curl_code;} else {echo 'connection failed, status code :'. $ curl_code ;}
http://www.baidu.com/The returned value is 200;
http://www.baidu.com/xxxThe returned result is 302, which is being accessed,http://www.baidu.com/xxxJumphttps://www.baidu.com/search/error.htmlThis is the case.
I think you can get the file content first to determine whether html tags exist! There is nothing to worry about.
curlSimulate a visit and check whether the returned value is correct.
Curl determines whether http status is 200