Deprecated: Function eregi() is deprecated

the same error has propped up within these admincp files i am trying to set up on my server. how can i resolve them?

Deprecated: Function eregi() is deprecated in C:xampphtdocsspeedyautosadmincpsystem_cls.php on line 152 (lines 152-155 shown)

if (!eregi("install", $_SERVER['REQUEST_URI']) && !eregi("install", $_SERVER['PHP_SELF']))
                {
                                exit("No " . TABLE_PREFIX . "db.php Present. Please run Install first");
                }

Deprecated: Function eregi() is deprecated in C:xampphtdocsspeedyautosadmincpsystem_cls.php on line 177 (lines 177-184 shown)

if (!eregi("install", $_SERVER['REQUEST_URI']) && !eregi("install", $_SERVER['PHP_SELF']) && !eregi("upgrade", $_SERVER['PHP_SELF']) && !eregi("admincp", $_SERVER['REQUEST_URI']) && !eregi("searchjs.php", $_SERVER['REQUEST_URI']) && !eregi("locationjs.php", $_SERVER['REQUEST_URI']))
{
                register_shutdown_function("SysTime");
                if (!verifysession() && ($SystemInfo->_systemstatus['User_Signup'] != "F" || $SystemInfo->_systemstatus['Seller_Signup'] != "F" || $SystemInfo->_systemstatus['Dealer_Signup'] != "F"))
                {
                                eval("$loginlink = "" . $Template->gettemplate("register_link") . "";");
                }
}

Deprecated: Function eregi() is deprecated in C:xampphtdocsspeedyautosadmincpfunc.php on line 447 (lines 442-451 shown)

if (!$GLOBALS['noshutdownfunc'])
                {
                                register_shutdown_function("CleanSessionTbl");
                }

} elseif (!eregi("install", $_SERVER['REQUEST_URI']) AND !eregi("install", $_SERVER['PHP_SELF']))
{
                echo "Please delete the install.php file";
                exit;
}

many thanks in advance!


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'])

eregi("install", $_SERVER['REQUEST_URI'])更改为preg_match("/install/i", $_SERVER['REQUEST_URI'])


Your concerns come a bit late. These functions have been deprecated since around PHP4. It's just the error messages which are new. If that's all you care about, then set error_reporting() or the error_level in the php.ini

You can convert almost any ereg() function into a preg_match() by simply adding some /regex/ delimiters. In your specific examples you can however just use stripos() by switching the arguments:

 stripos($_SERVER['REQUEST_URI'], "install")
链接地址: http://www.djcxy.com/p/92806.html

上一篇: 在php中验证电子邮件

下一篇: 弃用:函数eregi()已弃用