不推荐使用:函数eregi()不推荐使用 [英] Deprecated: Function eregi() is deprecated in

查看:125
本文介绍了不推荐使用:函数eregi()不推荐使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to submit values to the database but i get an error message

不建议使用:函数eregi()已弃用 C:\ wamp \ www \ OB \ admin_add_acc.php在第20和27行上

Deprecated: Function eregi() is deprecated in C:\wamp\www\OB\admin_add_acc.php on line 20 and 27

这是代码:

<?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
{                       

推荐答案

eregi() 已弃用从PHP 5.3开始,请使用 preg_match() .

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

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
        {
        }
    }
} 

这篇关于不推荐使用:函数eregi()不推荐使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆