更新时间:2023-02-23 09:25:33
if (strpos($str, '.') !== FALSE)
{
echo 'Found it';
}
else
{
echo 'Not found.';
}
请注意,您需要与!==
运算符进行比较.如果使用!=
或<>
并且'.'
在位置0
上找到,嘿! 0
比较等于FALSE
,您输了.这样一来,您就可以在周末将生产网站指向开发数据库,而在星期一返回时就不会感到无穷无尽.
Note that you need to compare with the !==
operator. If you use !=
or <>
and the '.'
is found at position 0
, hey! 0
compares equal to FALSE
and you lose. This will cause you to point a production website at a development database over the weekend, causing no end of joy when you return monday.