-1

我一直在升级一些脚本以使用最近的编码,但这个对我来说很重要。我已经进行了一些切换以使用 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];
    }

有人可以在这里帮忙进行转换吗,这会导致更多的标题问题,并且它一直在阻止我试图确定这个以使其正确...我希望他们让我们运行旧脚本选项,但我的服务器没有!

如果你愿意为我承担这个,我可以给你一个 lin,我厌倦了看到标题错误,几年前我写这些脚本时,它们总是让我头疼,我的编码是边缘的,几乎不能容忍 tp php 但现在它让我修复了这些小错误,而 preg 电话就是一个让我痛心的电话

我知道这是一个被广泛讨论的话题,我看了几十个,但每次我尝试转换它都失败了,我认为由于它们定义路径的方式,我试图重新考虑代码,但它只会变得更糟,

任何人?

4

1 回答 1

1

改用:preg_replace_ereg_replace

 mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )

自 PHP 5.3.0 起,ereg_replace 已被弃用。强烈建议不要依赖此功能。

http://php.net/manual/en/function.preg-replace.php

于 2014-08-04T19:37:38.673 回答