参见英文答案 >
How can I convert ereg expressions to preg in PHP? 4个
函数eregi()已弃用.我怎样才能取代eregi().我尝试使用preg_match然后停止工作.
函数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'; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。