我在变量中收到如下文字:
$text = 'This is a code snippet';
现在我想在[cdata] ... [!cdata]中附上上述文字。
echo $ text的输出应如下所示:
[cdata]This is a code snippet[!cdata]
我该怎么做?
感谢。
答案 0 :(得分:1)
尝试
$text = 'This is a code snippet';
$text = '[cdata]'.$text.'[!cdata]';
echo $text;
答案 1 :(得分:0)
试试这个
$text = "This is a code snippet";
$text = "[cdata]{$text}[!cdata]";
echo $text;