2012-04-07 80 views
0

以下两行给予警告,过时的功能已被弃用ereg_replace()和eregi()

if (eregi($patt,$v,$res)) 
Deprecated: Function eregi() is deprecated in /classes/xtpl.php on line 50 

$copy=ereg_replace("\{".$v."\}","$var",$copy); 

Deprecated: Function ereg_replace() is deprecated in /classes/xtpl.php on line 25 

我有尝试以下方式使用preg_match(),但未能解决问题

$copy=preg_match("\{".$v."\}","$var",$copy); 
if (preg_match($patt,$v,$res)) 

请给点意见

回答

1

这些功能,因为PHP 5.3,不推荐。 使用preg_replace而不是ereg_replace和preg_match而不是eregi。 您可能会发现关于这些功能的必要信息这里 - http://www.php.net/manual/en/function.preg-replace.php http://www.php.net/manual/en/function.preg-match.php

在此之后
+0

我已经取代带preg_replace的ereg_replace和带preg_match的prereg_replace,preg_replace工作正常,但使用preg_match我得到空白页 – mack 2012-04-07 06:58:36

+0

请参阅它在php手册中的用法。我提供了链接。 – Sushant 2012-04-07 09:20:25