Home > php教程 > php手册 > 弄了个检测传输的参数是否为数字的Function

弄了个检测传输的参数是否为数字的Function

WBOY
Release: 2016-06-13 12:35:43
Original
1269 people have browsed it

/*判断专传输数据是否为数字 
用正则表达式判断输入的数字是否合法 
调用:checknum(参数1,参数2) 

*/ 

复制代码 代码如下:

function checknum($id,$say)  
{  
            $inid=$id;  
            if(!ereg("^(-{0,1}|\+{0,1})[0-9]+(\.{0,1}[0-9]+)$",$inid))  
        {  
        echo $say.",入口:"."".$inid."";  
            exit;  
        }  
}  



调用 

复制代码 代码如下:

$tid="111fff";  
checknum($tid,"数字非法")  
?>  

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template