Php 将preg_replace更改为preg_replace_回调无效

Php 将preg_replace更改为preg_replace_回调无效,php,regex,preg-replace,preg-replace-callback,Php,Regex,Preg Replace,Preg Replace Callback,我有php代码: preg_replace('#<!-- '.(($c)?'\#':'').'BEGIN '.$block.' -->[\r\n]*(.*?)[\r\n]*<!-- '.(($c)?'\#':'').'END '.$block.' -->#se', '$s = stripslashes("\\1");',$str); preg#u replace('#[\r\n]*(.*)[\r\n]*#se', “$s=stripslashes

我有php代码:

preg_replace('#<!-- '.(($c)?'\#':'').'BEGIN '.$block.' -->[\r\n]*(.*?)[\r\n]*<!-- '.(($c)?'\#':'').'END '.$block.' -->#se',
            '$s = stripslashes("\\1");',$str);
preg#u replace('#[\r\n]*(.*)[\r\n]*#se',
“$s=stripslashes(\\1”);”,$str);
现在我改为:

preg_replace_callback('#<!-- '.(($c)?'\#':'').'BEGIN '.$block.' -->[\r\n]*(.*?)[\r\n]*<!-- '.(($c)?'\#':'').'END '.$block.' -->#s',
                function($m){
                return $s = stripslashes($m[1]);},
                $str);
preg\u replace\u回调('#[\r\n]*(.*)[\r\n]*#s',
功能(百万美元){
返回$s=stripslashes($m[1]);},
$str);
但也不起作用,不显示错误

帮帮我,谢谢

这是我加载html文件的函数

var $ext = ".html";
var $cache_temp = array();
function get_htm($filename,$blockname = '',$c = false) {
    $full_link = $_SESSION['skin_folder']."/".$filename.$this->ext;
    if (!file_exists($full_link)) {
        die("Không tìm thấy file : <b>".$full_link."</b>");
    }
    if ($this->cache_temp['file_'.$filename]) $file_content = $this->cache_temp['file_'.$filename];
    else {
        $this->cache_temp['file_'.$filename] = $file_content = file_get_contents($full_link);
    }
    return $file_content;
}

function get_block_from_htm($str,$block = '',$c = false) {

    if (!$this->cache_temp['block_'.$block]) {
        preg_replace('#<!-- '.(($c)?'\#':'').'BEGIN '.$block.' -->[\r\n]*(.*?)[\r\n]*<!-- '.(($c)?'\#':'').'END '.$block.' -->#se','$s = stripslashes("\1");',$str);
        if ($s != $str) $str = $s;
        else $str = '';
        $this->cache_temp['block_'.$block] = $str;
    }
    return $this->cache_temp['block_'.$block];
}
var$ext=“.html”;
var$cache_temp=array();
函数get_htm($filename,$blockname='',$c=false){
$full\u link=$\u会话['skin\u folder'].“/”$filename.$this->ext;
如果(!file_存在($full_链接)){
死(“khong tìm thấy文件:“.$full_link.”;
}
如果($this->cache_temp['file.'$filename])$file_content=$this->cache_temp['file.'$filename];
否则{
$this->cache\u temp['file\u.'$filename]=$file\u content=file\u get\u contents($full\u link);
}
返回$file\u内容;
}
函数get_block_from_htm($str,$block='',$c=false){
如果(!$this->cache_temp['block.'$block]){
preg#u replace(“#[\r\n]*(.*?[\r\n]*#se”,“$s=stripslashes(“\1”);”,$str);
如果($s!=$str)$str=$s;
其他$str='';
$this->cache_temp['block.'$block]=$str;
}
返回$this->cache_temp['block.'$block];
}
html文件如下所示

bot.html
机器人现在在线
  • abc123
... last_search.html 最后搜索
  • def456

什么是
$str
$c
$block
?什么是“不工作”?@chris85我已经更新了我的问题,谢谢@Rizier123在我的更新代码之后,我的页面没有显示任何内容。@Đỗ不及物动词ế塔纳姆:检查。