Addslashes()與 stripslashes()配對使用
輸入到數據庫是:
addslashes();轉義
例如:’admin’ 使用addslashes函數存入數據庫爲:/’admin/’
讀取數據庫是:
stripslashes();
例如:/’admin/’ 輸出時使用stripslashes函數將爲:admin
還原數據!
Mysql_real_escape_string()與 stripslashes()配對使用
將magic_quotes_gpc=off 一定要打開
<?php
$str='<a href="test.html">測試頁面</a>';
echo htmlentities($str);//此輸出將會出現亂碼
$str='<a href="test.html">測試頁面</a>';
echo htmlspecialchars($str);//此輸出正常
?>
搜索關鍵字加紅和加粗
<?php
$strs=preg_replace("/($keyword)/i","<font color='#ff0000'>//1</font>",$rs['title']);
echo $strs;?>