【发布时间】:2012-11-14 15:35:17
【问题描述】:
【问题讨论】:
【问题讨论】:
使用str_contains 函数。
if (str_contains($str, "."))
{
echo 'Found it';
}
else
{
echo 'Not found.';
}
if (strpos($str, '.') !== FALSE)
{
echo 'Found it';
}
else
{
echo 'Not found.';
}
请注意,您需要使用!== 运算符。如果您使用!= 或<> 并且'.' 位于0 位置,则比较将评估为真,因为0 大致等于false。
【讨论】:
if (count(explode('.', $string)) != 2) { //string don't have dot }
您可以使用stristr() 或strpos()。如果没有找到,两者都返回 false。
【讨论】: