Home  >  Article  >  Backend Development  >  php ereg() email verification and file name verification_PHP tutorial

php ereg() email verification and file name verification_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 16:59:041124browse

php tutorial ereg() email verification and file name verification
String comparison analysis.

Syntax: int ereg(string pattern, string string, array [regs]);

Return value: integer/array

Function type: Data processing




Content Description


This function uses pattern rules to parse and compare string strings. The value returned by the comparison result is placed in the array parameter regs. The content of regs[0] is the original string, regs[1] is the first string that conforms to the rules, and regs[2] is the second string that conforms to the rules. string, and so on. If the parameter regs is omitted, it will simply be compared, and the return value will be true if found.


Usage examples
This example was proposed by markus@dnet.it on 14-jun-1999. It can perform a simple check on the e-mail input by the user to check whether the user's e-mail string has an @ character before the @ character. There are English letters or numbers, followed by a number of strings, and there can only be two or three English letters after the last decimal point. super@mail.wilson.gs can pass the check, but super@mail.wilson cannot pass the check.

if (eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$ email)) {
echo "Your e-mail passed preliminary check";
}
?>

Take a look

dedecms file verification

if(!eregi("^[a-z0-9_-]{1,}.lib.php$",$filename))
{
Showmsg('The file is not a standard tag fragment file and is not allowed to be edited here!','-1');
exit();
}
$fp = fopen(dedeinc.'/taglib/'.$filename,'r');
$democode = fread($fp,filesize(dedeinc.'/taglib/'.$filename));
fclose($fp);
$title = "Modify Label";

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631348.htmlTechArticlephp tutorial ereg() email verification and file name verification string comparison and analysis. Syntax: int ereg(string pattern, string string, array [regs]); Return value: integer/array Function type: Information office...
Statement:
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