PHP ereg () mailbox validation and file name Validation _php tutorial

Source: Internet
Author: User
Tags ereg
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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.