【发布时间】:2014-09-11 11:15:08
【问题描述】:
您好,我无法用美元符号替换字符串
$string = "The $NAME brown fox jumped over the lazy dog.";
echo preg_replace('/\$NAME/', "Sample Name", $string);
输出:
The brown fox jumped over the lazy dog.
问题是 $NAME 没有替换为 Sample Name。 如果有任何帮助可以解决我的问题,我会很高兴。
【问题讨论】:
-
由于你没有做任何正则表达式搜索和替换,我建议使用 str_replace 代替。
标签: php replace str-replace