use*_*318 1 php regex preg-match
对不起,我对正则表达式有点新手,无论如何我都有一个网址http://example.com/test/folder/?get=ThisisaValue,我需要它来返回"get"这个词是否存在.
每当我运行该功能时,我得不到匹配?任何帮助表示赞赏谢谢.
示例代码,假设$_SERVER['HTTP_REFERER']是http://example.com/hello/?state=12345
if(preg_match("state", $_SERVER['HTTP_REFERER'])) {
echo "match";
} else {
echo "no match";
}
Run Code Online (Sandbox Code Playgroud)
我需要它来返回"get"这个词是否在那里
在这种情况下,您不需要匹配任何东西 - 您可以使用,检查字符串是否在字符串中strpos().
if (strpos($url, 'get')) {
// do something
}
Run Code Online (Sandbox Code Playgroud)