![]() |
|
|||||||
|
Welcome to the PHPCentral.com forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! |
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Posts: n/a
|
This is the function which will validate url:
PHP Code:
Use of function : PHP Code:
|
|
|
|
#2 |
|
Posts: n/a
|
how about this i made yesterday;
THE CODE - one liner PHP Code:
(OPTIONAL: READ BELOW FOR EXPLANATION) it will validate all these types of urls PHP Code:
THE CODE - broken into section for easy editing and understanding: PHP Code:
all the lines in the code above can be safely removed (except for hostname) if you don't want to allow some URL segment (if you don't want getqueries in your urls, just comment the respective $urlregex .= ....) - but do not reorder them. the "(optional)" states that the part MAY exist, but url will be valid even if it doesn't contain the part (see the valid urls above). syntax: Code:
-assuming .. (dot dot) is never allowed in hostname or path FEEDBACK IS APPRECIATED |
|
|
|
#3 |
|
Posts: n/a
|
Thanks, fqa, this function worked great for me.
|
|
|
|
#4 |
|
Posts: n/a
|
Hello fqa, while your code works for the URL patterns you have posted, however it does pass URLs like http://a or http://fkhdfkjhkjfd thus making the code almost useless.
|
|
|
|
#5 |
|
Junior Member
Join Date: Apr 2009
Posts: 1
![]() |
1r0nH1de check this comment
// http://x = allowed (ex. http://localhost, http://routerlogin) thanks a lot fqa! |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|