用正则表达式判断输入的数字是否合法的例子
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
$in="2344";
if(ereg("^(-{0,1}|+{0,1})[0-9]+(.{0,1}[0-9]+)$",$in))
echo "Ok!";
else
echo "Sorry,Please input again!";
?>
<br>很简单的嘛!
</body>
</html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
$in="2344";
if(ereg("^(-{0,1}|+{0,1})[0-9]+(.{0,1}[0-9]+)$",$in))
echo "Ok!";
else
echo "Sorry,Please input again!";
?>
<br>很简单的嘛!
</body>
</html>
- 上一篇:一个全PHP编写的树型目录结构
- 下一篇:实现跨域名Cookie
精彩图集
精彩文章