I want to verify a URL submitted by users to make sure they didn't link to a missing page or have a typo in the URL.
I can use get_headers() for this.
The problem is redirections will send multiple headers. Will the 200 OK response always be the last status header sent in the output from get_headers() ? Also, will the status always be 200 OK or will there be other successful header types?
verifying a URL submitted [solved]
Moderator: General Moderators
verifying a URL submitted [solved]
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: verifying a URL submitted
Would the following work?
It appears to work in a few examples I've thrown at it.
Code: Select all
function header200($headers)
{
foreach ($headers AS $header)
{
if (stripos($header, '200 ok') !== false)
{
return true;
}
}
return false;
}
var_dump(header200('url'));Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: verifying a URL submitted
Nevermind, solved it myself. 
1) Verify http:// or https:// with preg_match or stripos
2) Verify parse_url can parse it
3) Verify it sends headers
4) Verify the header is 200 ok using the function above.
Sorry guys.
1) Verify http:// or https:// with preg_match or stripos
2) Verify parse_url can parse it
3) Verify it sends headers
4) Verify the header is 200 ok using the function above.
Sorry guys.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.