Home > Backend Development > PHP Tutorial > fun factory has a Function that detects whether the transmitted parameters are numbers.

fun factory has a Function that detects whether the transmitted parameters are numbers.

WBOY
Release: 2016-07-29 08:35:28
Original
930 people have browsed it

/*Judge whether the transmitted data is a number
Use regular expressions to determine whether the entered number is legal
Call: checknum(parameter 1, parameter 2)
*/

Copy the code The code is as follows:

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

Call



Copy code The code is as follows:$tid="111fff";

checknum($tid,"Illegal number")
?>

The above introduces the function of fun factory to detect whether the transmitted parameters are numbers, including the content of fun factory. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template