dongsuichi6529 2011-04-18 09:18
浏览 31
已采纳

函数eregi()已弃用[重复]

This question already has an answer here:

Function eregi() is deprecated. How can i replace eregi(). I try with preg_match but then stop working.

i us ethis help:

http://takien.com/513/how-to-fix-function-eregi-is-deprecated-in-php-5-3-0.php

CODE BEFORE:

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';
        }

CODE THEN:

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';
        }
</div>
  • 写回答

3条回答 默认 最新

  • duanaoreng9355 2011-04-18 09:22
    关注

    preg_match expects its regex argument to be within a pair delimiters.

    So try:

    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'; 
    }     
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件