也许我问的问题有点太平庸了,但我真的不知道如何使用PHP检查字符串中是否出现通配符(*)字符。
示例字符串:*bcd
OR ab*d
OR abc*
无论我尝试使用什么PHP函数,它的行为都不可预测。我只需要知道通配符是否在字符串中。非常感谢您的回复!
if (strpos($mystring, '*') === false) {
echo "Wildcard was not found in the string '$mystring'";
} else {
echo "Wildcard was found in the string '$mystring'";
}
基于http://php.net/manual/en/function.strpos.php