php(preg)无法工作,函数ereg_replace()已被弃用

php(preg)无法工作,函数ereg_replace()已被弃用,php,preg-replace,ereg,Php,Preg Replace,Ereg,我一直在升级一些脚本,以使用最新的编码,但这一个是我。我已经做了一些转换来使用preg,但这段代码似乎在反击 这是我需要替换的代码部分,它是用于轮询的代码部分 function pre_parse($filename) { if (isset($this->pre_output[$filename]) && !empty($this->pre_output[$filename])) { return $this->pre

我一直在升级一些脚本,以使用最新的编码,但这一个是我。我已经做了一些转换来使用preg,但这段代码似乎在反击

这是我需要替换的代码部分,它是用于轮询的代码部分

 function pre_parse($filename) {
        if (isset($this->pre_output[$filename]) && !empty($this->pre_output[$filename])) {
            return $this->pre_output[$filename];
        }
        if (isset($this->vars[$filename])) {
            reset($this->vars[$filename]);
            $this->pre_output[$filename] = ereg_replace("\"", "\\\"", $this->files[$filename]);
            while(list($name, $value) = each($this->vars[$filename])) {
                $value = ereg_replace("\"", "\\\"", $value);
                $this->pre_output[$filename] = str_replace($this->start.$name.$this->end, $value, $this->pre_output[$filename]);
            }
        } else {
            $this->pre_output[$filename] = ereg_replace("\"", "\\\"", $this->files[$filename]);
        }
        return $this->pre_output[$filename];
    }
有人能在这里帮助转换,它导致了更多的标题问题,它一直在阻碍我尝试钉这一个,以使其恰到好处。。。我希望他们让我们运行遗留脚本选项,但我的服务器没有

我可以pm你一林,如果你愿意为我,我讨厌看到标题错误。几年前,当我写这些脚本时,它们总是让我头疼。我的编码是边缘的,几乎不能容忍tp php,但现在它让我修复这些小错误,preg调用是一个让我痛心的问题

我知道这是一个涉及面很广的话题,我看了几十个,但每次我尝试转换都失败了,我想因为路径的定义方式,我试图重新思考代码,但结果只会变得更糟


有人吗?

使用
preg\u replace
代替
ereg\u replace

 mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
从PHP5.3.0开始,ereg_replace已被弃用。依靠这个 这项功能非常不受欢迎


对于ereg\U replace(“\”“,“\\\\”,$value)”,您不需要preg\u replace;,使用str\u replace(“\”、“\ \ \”、$value)可以获得相同的结果;好的,谢谢,我现在在上班,但我回家后会试试。非常感谢。