1
我正在寻找一种方法,我可以使用代码片段,但安全地将它们插入数据库并将它们拉出。htmlentities变量不起作用
我有以下部分代码。
<?php $snippet = htmlentities("<?php
define ('EMOTICONS_DIR', '/images/emoticons/');
function BBCode2Html($text) {
$text = trim($text);
// BBCode [code]
?>"); ?>
<pre class="prettyprint">
<?php echo $snippet; ?>
</pre>
但是当我尝试在浏览器中运行代码时出现以下错误。
Notice: Undefined variable: text in C:\xampp\htdocs\prettycss\index.php on line 18
Notice: Undefined variable: text in C:\xampp\htdocs\prettycss\index.php on line 18
Notice: Undefined variable: text in C:\xampp\htdocs\prettycss\index.php on line 21
这对我说htmlentities不符合$符号什么是最好的方法呢?
感谢