不推荐使用:函数eregi()已弃用

Jus*_*ush 12 php eregi

我正在尝试向数据库提交值,但我收到一条错误消息

不推荐使用:函数eregi()在第20行和第27行的C:\ wamp\www\OB\admin_add_acc.php中已弃用

这是代码:

<?php       

include 'db_connect.php'; 

if(isset($_POST['Submit']))           
{            
$acc_type=ucwords($_POST['acc_type']);
$minbalance=ucwords($_POST['minbalance']);                       
if (!eregi ("^[a-zA-Z ]+$", stripslashes(trim($acc_type))))//line 20 
{                 
echo "Enter Valid Data for Account Type!";                
exit(0);                 
}           
else 
{                  
if (!eregi ("^[0-9 ]+$", stripslashes(trim($minbalance))))//line 27
{                       
Run Code Online (Sandbox Code Playgroud)

Mis*_*Bla 18

eregi()自PHP 5.3起不推荐使用,请preg_match()改用.

请注意,在正则表达式中preg_match()传递i修饰符时,仅区分大小写.

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
        {
        }
    }
} 
Run Code Online (Sandbox Code Playgroud)