如何使用 PHP 将文本包含在 [cdata]...[!cdata] 中?
How to enclose text within [cdata]...[!cdata] using PHP?
我在变量中获取文本如下:
$text = 'This is a code snippet';
现在我想将上述文本包含在 [cdata]...[!cdata] 中。
echo $text 的输出应该如下所示:
[cdata]This is a code snippet[!cdata]
我应该怎么做?
谢谢。
尝试
$text = 'This is a code snippet';
$text = '[cdata]'.$text.'[!cdata]';
echo $text;
试试这个
$text = "This is a code snippet";
$text = "[cdata]{$text}[!cdata]";
echo $text;
我在变量中获取文本如下:
$text = 'This is a code snippet';
现在我想将上述文本包含在 [cdata]...[!cdata] 中。
echo $text 的输出应该如下所示:
[cdata]This is a code snippet[!cdata]
我应该怎么做?
谢谢。
尝试
$text = 'This is a code snippet';
$text = '[cdata]'.$text.'[!cdata]';
echo $text;
试试这个
$text = "This is a code snippet";
$text = "[cdata]{$text}[!cdata]";
echo $text;