PHP regex for url validation, filter_var is too permisive

前端 未结 3 1584
后悔当初
后悔当初 2020-12-11 21:18

First lets define a \"URL\" according to my requirements.

The only protocols optionally allowed are http:// and https://

then a man

3条回答
  •  半阙折子戏
    2020-12-11 21:39

    You could use parse_url to break up the address into its components. While it's explicitly not built to validate a URL, analyzing the resulting components and matching them against your requirements would at least be a start.

提交回复
热议问题