简体   繁体   中英

PHP FILTER_VALIDATE_URL Maximum Length?

I have this code to validate whether a URL inputted is valid...

if(filter_var($param1, FILTER_VALIDATE_URL) === FALSE){
    echo "invalidURL";
    exit();
}

But when testing with this long-yet-valid url it says it's invalid...

http://www.thisurlislongthisurlislongthisurlislongthisurlislongthisurlislongthisurlislongthisurlislongthisurlislongthisurlislong.com

Anyone have any ideas why? I can't find anything in FILTER_VALIDATE_URL that says it should consider a url of this length to be invalid, but simply by deleting characters it will eventually be deemed valid. Thanks for any thoughts!

Sorry all, just found this after a little more research...

"According to RFC 1034 , each part of domain name label cannot exceed 63 characters."

(source: http://grokbase.com/t/php/php-git-pulls/149gqytbpr/pr-php-src-826-master-filter-validate-url-check-max-length-of-domain-name-label ).

So it wasn't a valid URL after all - well done php!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM