• PHP Video Tutorials

PHP - Function eregi()


Advertisements

Syntax

int eregi(string pattern, string string, [array regs]);

Definition and Usage

The eregi() function searches throughout a string specified by pattern for a string specified by string. The search is not case sensitive. Eregi() can be particularly useful when checking the validity of strings, such as passwords.

The optional input parameter regs contains an array of all matched expressions that were grouped by parentheses in the regular expression.

Return Value

  • It returns true if the pattern is validated, and false otherwise.

Example

Following is the piece of code, copy and paste this code into a file and verify the result.

<?php
   $password = "abc";
   
   if (! eregi ("[[:alnum:]]{8,10}", $password))
   {
      print "Invalid password! Passwords must be from 8 - 10 chars";
   } else {
      print "Valid password";
   }
?>

This will produce the following result −

Invalid password! Passwords must be from 8 - 10 chars
php_regular_expression.htm

Useful Video Courses


Video

PHP Online Training

45 Lectures 9 hours

Malhar Lathkar

Video

Become PHP Facebook Developer: Password-Less Authentication

34 Lectures 4 hours

Syed Raza

Video

Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain

Video

Learn PHP from Scratch

17 Lectures 1 hours

Nivedita Jain

Video

E Commerce Website Development In PHP With PDO

100 Lectures 34 hours

Azaz Patel

Video

PHP in Telugu

43 Lectures 5.5 hours

Vijay Kumar Parvatha Reddy

Advertisements