PHP防止XSS***

mysql_real_escape_string() 

所以得SQL語句如果有類似這樣的寫法:"select * from cdr where src =".$userId; 都要改成 $userId=mysql_real_escape_string($userId) 

所有有打印的語句如echo,print等 在打印前都要使用htmlentities() 進行過濾,這樣可以防止Xss,注意中文要寫出htmlentities($name,ENT_NOQUOTES,GB2312) 。 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章