Various people have contributed through the comments in the other blog post.So here I have better control over the spam and can open the comments again.Up until now I always discarded them as being to “geeky”, meaning i don’t consider it my life’s biggest goal to be typing (/?\w) all day long (so why did i become a programmer, aaaah yes to make life easier for other people) Anyway.. Simeon pilgrim indicated that the ftp urls won’t validate when you add a username and a password.Currently there are numerous solutions for validating URLs. the real issuse is that both methods dont check for "FILTER_FLAG_HOST_REQUIRED" which actually doesent work altough it should check ending... I have been trying to find a good solution for testing for URL's, I would not use the filter_var() for this kind of check. The only way i have found to check for them is either use regex or use the parse_url and check each section.
Let's construct a Reg Ex to match any of them, step by step.First we should define the different parts we want to match and what they can be made of. This Name can contain every letter defined in the Unicode spec (This includes Emojis, btw).The Top Level Domain is probably the easiest to match.One solution is to use filter_var for your initial validation and then perform additional validation checks if the original filter_var validation passes.Validating URLs is important to form handling and PHP data processing.