【发布时间】:2012-06-28 20:06:54
【问题描述】:
我如何创建一个 if 语句来检查字符串是否包含正斜杠?
$string = "Test/Test";
if($string .......)
{
mysql_query("");
}
else
{
echo "the value contains a invalid character";
}
【问题讨论】:
-
strpos():if (strpos($string, '/') !== FALSE) { echo "It contains a /"; } -
您可能会发现
s($str)->contains('/')很有帮助,如this standalone library 中所示。
标签: php string if-statement