Deprecated: Function eregi() is deprecated in
eregi()
is deprecated as of PHP 5.3, use preg_match()
instead.
Note that preg_match()
is only case insensitive when you pass the i
modifier in your regular expression.
include 'db_connect.php';
if(isset($_POST['Submit']))
{
$acc_type=ucwords($_POST['acc_type']);
$minbalance=ucwords($_POST['minbalance']);
// Removed A-Z here, since the regular expression is case-insensitive
if (!preg_match("/^[a-z ]+$/i", stripslashes(trim($acc_type))))//line 20
{
echo "Enter Valid Data for Account Type!";
exit(0);
}
else
{
// \d and 0-9 do the same thing
if (!preg_match("/^[\d ]+$/", stripslashes(trim($minbalance))))//line 27
{
}
}
}
Deprecated: Function eregi_replace()
the entire ereg family of functions are deprecated in PHP and will at some point be removed from the language. The replacement is the preg family. For the most part, the change is simple:
preg_replace('/[^<>]>/i', '', $question);
^-- ^ ^^
- change ereg to preg
- add delimeters (
/
) - for case insensitive matches (ereg
i
), add thei
modifier
Deprecated: Function eregi() is deprecated
Normally, you should use the preg_* family of regular expression matching. However, most of your ereg
calls actually just search case insensitive. Instead of
!eregi("install", $_SERVER['PHP_SELF'])
use
stripos($_SERVER['PHP_SELF'], 'install') === false
. With preg_match, this would look like this:
!preg_match('/install/i', $_SERVER['PHP_SELF'])
Alternative for deprecated PHP function: eregi_replace
preg_replace
https://php.net/preg-replace
$pattern = "/([a-z0-9][_a-z0-9.-]+@([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,6})/i";
$replace = "<a href=\"mailto:\\1\">\\1</a>";
$text = preg_replace($pattern, $replace, $text);
PHP Form Validation - Deprecated Function eregi()
Regex has the "case-insensitive" way to match a string. If you put the letter "i"
at the end of the regular expression, the function preg_match() will match the string even if you are searching a lowercase sentence in an uppercase string.
In the case ALPHA, you can use this regular expression:
$exp = "/^[a-z]+$/i";
instead of
$exp = "^[a-z]+$";
Using this, you can change the PHP functions from eregi($exp, $value)
to preg_match($exp, $value)
, which will return TRUE
if there are matches.
You can read the related documentation of preg_match() function here: https://www.php.net/manual/en/function.preg-match.php
Andrea
Related Topics
Split Array into Two Arrays by Index Even or Odd
PHP Simplexml Attributes Are Missing
Display Custom Order Meta Data Value in Email Notifications Woocommerce
How to Get a One-Dimensional Scalar Array as a Doctrine Dql Query Result
Mysql_Escape_String VS MySQL_Real_Escape_String
Create New Xml File and Write Data to It
Search and Replace Multiple Values with Multiple/Different Values in PHP5
Add PHP Variable Inside Echo Statement as Href Link Address
Laravel Compact() and ->With()
How to Display Xml in HTML in PHP
PHP Foreach by Reference Causes Weird Glitch When Going Through Array of Objects
Using PHP as a Template Engine
How to Escape Single-Quote (Apostrophe) in String Using PHP
MySQL and PHP - Insert Null Rather Than Empty String
How to Set Cron Job Url for Codeigniter
How to Select All Column Name from a Table in Laravel
In MVC, Where Do You Draw the Line Between a Controller and Model