PHP filter_var() - FILTER_VALIDATE_URL

后端 未结 3 1799
自闭症患者
自闭症患者 2020-12-19 09:11

The FILTER_VALIDATE_URL filter seems to have some trouble validating non-ASCII URLs:

var_dump(filter_var(\'http://pt.wikipedia.org/wiki/\', FILT         


        
3条回答
  •  失恋的感觉
    2020-12-19 09:42

    Technically that is not a valid URL according to section 5 of RFC 1738. Browsers will automatically encode the ã character to %C3%A3 before sending the request to the server. The technically valid full url here is: http://pt.wikipedia.org/wiki/Guimar%C3%A3es Pass that to the VALIDATE_URL filter and it will work fine. The filter only validates according to spec, it doesn't try to fix/encode characters for you.

提交回复
热议问题