Test if string is URL encoded in PHP

前端 未结 13 2104
不思量自难忘°
不思量自难忘° 2021-01-01 11:10

How can I test if a string is URL encoded?

Which of the following approaches is better?

  • Search the string for characters which would be encoded, which
相关标签:
13条回答
  • 2021-01-01 11:54

    well, the term "url encoded" is a bit vague, perhaps simple regex check will do the trick

    $is_encoded = preg_match('~%[0-9A-F]{2}~i', $string);
    
    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题