PHP eregi() Function
October 30, 2020
Hello dear readers! welcome back to another section of our tutorial on PHP. In this tutorial guide, we will be discussing about the PHP eregi() Function.
The PHP eregi() function searches throughout a string specified by pattern for a string specified by string. Search with this function is not case sensitive. The eregi() can be specifically very useful when checking for the validity of strings, such as password.
The optional input parameter regs contains an array of all matched expressions that were grouped by parentheses in the PHP's regular expression.
The PHP eregi() function searches throughout a string specified by pattern for a string specified by string. Search with this function is not case sensitive. The eregi() can be specifically very useful when checking for the validity of strings, such as password.
The optional input parameter regs contains an array of all matched expressions that were grouped by parentheses in the PHP's regular expression.
RECOMMENDED POST: PHP ereg_replace() Function
Syntax
The following is the syntax for the eregi() function -
int eregi(string pattern, string string, [array regs]);
Return Value
- It returns true if the pattern is validated, otherwise false.
Example
Following is a simple example -
<?php $password = "abc"; if (! eregi ("[[:alnum:]]{8,10}", $password)) { print "Invalid password! Passwords must be from 8 - 10 chars"; } else { print "Valid password"; } ?>
Output
When the above code is executed, it will produce the following result -
Invalid password! Passwords must be from 8 - 10 chars
RECOMMENDED POST: PHP ereg() Function
Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial guide, we are going to be discussing about the PHP eregi_replace() Function.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.