有没有可能在电子邮件表单中使用点.检查器,以便如果特定字段有点,则这将告诉用户不要在这些字段中放点。我已经尝试过了,但是不起作用:
if (eregi('.', $notes)) {
die ("Do NOT PUT DOT HERE");
}所以,你知道该怎么做吗?
发布于 2012-08-03 03:54:50
就像手册上说的:
提示:如果只想检查一个字符串是否包含在另一个字符串中,请不要使用preg_match()。使用strpos()或strstr()代替,因为它们会更快。
下面是strpos()方法:
<?php
$findme = '.';
$pos = strpos($notes, $findme);
if ($pos !== false) {
echo "Do NOT PUT DOT HERE";
} else {
//other
}
?>在大多数情况下,我不建议使用die\exit。
发布于 2012-08-03 03:51:09
if (preg_match('~\.~', $notes)) {
// Do something useful
}https://stackoverflow.com/questions/11784715
复制相似问题