Search code examples
phpfilterspam-prevention

PHP filter_var: FILTER_VALIDATE_URL include more cases


It only validates urls that are of the format: http://www.example.com

How do I also validate partial urls, such as: www.example.com, example.com, or blah/example.php, etc...

(I need to do this to filter out posts/comments that only contain a url)


Solution

  • I believe HTML has some new input types that do this for you, I dont know if it does it the way you want but here have a look! http://www.w3schools.com/html5/html5_form_input_types.asp