使用带ASCII字符的preg_replace

时间:2012-11-19 11:58:06

标签: php wordpress preg-replace

在我的functions.php中,我添加了一个用德语引号替换英语的函数。我通过简单的str_replace调用来做到这一点,如下所示:

 $content = str_replace (' “', ' „', $content);

现在我想用preg_replace做这个,所以我可以用不同的方式处理特殊情况。但是,这个:

 $haekchenunten = "“";
 $regex = /^ . $haekchenunten . /;
 $content = preg_replace ($regex, '„', $content);

导致空白页面(PHP Fatal,我认为)。

如何将“与preg_replace一起使用?

1 个答案:

答案 0 :(得分:0)

如果这是您的代码,请尝试使用引号; - )

 $regex = "/^" . $haekchenunten . "/";