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不符合$符號什麼是最好的方法呢?
感謝