本文分享一例防範XSS攻擊的php函式程式碼,學習下在php中防範XSS攻擊的方法,有需要的朋友參考學習下。
本節內容:
過濾XSS攻擊
以下函式:
過濾使用者的.輸入,保證輸入是XSS安全的。
例子:
複製程式碼 程式碼示例:
<?php
/**
* 過濾XSS攻擊
* edit:
*/
function RemoveXSS($val) {
// remove all non-printable characters. CR(0a) and LF(0b) and TAB(9) are allowed
// this prevents some character re-spacing such as <java