php – 函数eregi()已弃用
发布时间:2020-12-13 21:28:07 所属栏目:PHP教程 来源:网络整理
导读:参见英文答案 How can I convert ereg expressions to preg in PHP?????????????????????????????????????4个 函数eregi()已弃用.我怎样才能取代eregi().我尝试使用preg_match然后停止工作. 我们帮助他们: http://takien.com/513/how-to-fix-function-eregi
参见英文答案 >
How can I convert ereg expressions to preg in PHP?????????????????????????????????????4个
函数eregi()已弃用.我怎样才能取代eregi().我尝试使用preg_match然后停止工作. 我们帮助他们: http://takien.com/513/how-to-fix-function-eregi-is-deprecated-in-php-5-3-0.php 代码之前: if ( ! eregi("convert$",$this->library_path)) { if ( ! eregi("/$",$this->library_path)) $this->library_path .= "/"; $this->library_path .= 'convert'; } if (eregi("gd2$",$protocol)) { $protocol = 'image_process_gd'; } 代码然后: if ( ! preg_match("convert$/i",$this->library_path)) { if ( ! preg_match("/$/i",$this->library_path)) $this->library_path .= "/"; $this->library_path .= 'convert'; } if (preg_match("gd2$/i",$protocol)) { $protocol = 'image_process_gd'; } 解决方法
preg_match期望它的正则表达式参数在一对分隔符内.
所以尝试: if ( ! preg_match("#convert$#i",$this->library_path)) { if ( ! preg_match("#/$#i",$this->library_path)) $this->library_path .= "/"; $this->library_path .= 'convert'; } if (preg_match("#gd2$#i",$protocol)) { $protocol = 'image_process_gd'; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |