Friday, May 10, 2013

Check whether url is valid with php

Use Filter Validator to validate url.

filter_var($url, FILTER_VALIDATE_URL);

Example using that,


if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
    die('Not a valid URL');
}

No comments:

Post a Comment