PHP Tutorial Ereg () mailbox validation and file name validation
Parsing of string alignment.
Syntax: int ereg (string pattern, string string, array [regs]);
return value: Integer/array
Function type: Data processing
Content Description
This function parses string strings with the rule of pattern. The value returned from the result is placed in the array parameter regs, Regs[0] content is the original string, string, Regs[1] is the first rule of the string, Regs[2] is the second rule of the string, and so on. If the parameter regs is omitted, it is simply a comparison, and the return value is true if found.
Usage examples
This example is proposed by markus@dnet.it in 14-jun-1999, the user can enter the e-mail to make a simple check, check whether the user's e-mail string has the @ character, before the @ character has an English letter or a number, after a few strings, after the last decimal point There can be only two or three English letters. Super@mail.wilson.gs can pass the inspection, Super@mail.wilson cannot pass the examination.
if (eregi ("^[_.0-9a-z-]+@" ([0-9a-z][0-9a-z-]+.) +[a-z]{2,3}$ ", $email)) {
echo "Your e-mail through a preliminary check";
}
?>
Take a look
Dedecms File Validation
if (!eregi ("^[a-z0-9_-]{1,}.lib.php$", $filename))
{
ShowMsg (' file is not a standard tag fragment file, not allowed in this edit! ', '-1 ');
Exit ();
}
$fp = fopen (dedeinc. ') /taglib/'. $filename, ' R ');
$democode = Fread ($fp, FileSize (dedeinc. ' /taglib/'. $filename));
Fclose ($FP);
$title = "Modify Label";
http://www.bkjia.com/PHPjc/631348.html www.bkjia.com true http://www.bkjia.com/PHPjc/631348.html techarticle PHP Tutorial Ereg () mailbox validation and file name validation string comparison resolution. Syntax: int ereg (string pattern, string string, array [regs]); return value: Integer/Array function type: Data Office ...