Checking for relative vs absolute paths/URLs in PHP

前端 未结 7 551
既然无缘
既然无缘 2021-01-17 15:45

I need to implement functions to check whether paths and urls are relative, absolute, or invalid (invalid syntactically- not whether resource exists). What are the range of

7条回答
  •  伪装坚强ぢ
    2021-01-17 16:17

    I think best is

    $test = [
    '/link?param=1'=>parse_url('/assa?ass'),
    '//aaa.com/link?param=1'=>parse_url('//assa?ass'),
    'http://aaa.com/link?param=1'=>parse_url('http://as.plassa?ass')
    ];
    

提交回复
热议问题