今天在利用一個正則時提示Deprecated: Function eregi() is deprecated in錯誤了,后來查詢了一原因是我們php5.3,在5.3中己經不支持eregi函數了,可以直接使用preg_match來代替。
改前代碼如下:
- function inject_check($sql_str) {
- $sql_str = strtolower($sql_str);
- return eregi('fopen|post|eval|select|insert|and|or|update|delete|'|/*|*|../|./|union|into|load_file|outfile', $sql_str); // 進行過濾
- }
改后的代碼:注意preg_match那一句:
- function inject_check($sql_str) {
- $sql_str = strtolower($sql_str);
- return preg_match('/fopen|post|eval|select|insert|and|or|update|delete|'|/*|*|../|./|union|into|load_file|outfile/', $sql_str); // 進行過濾
- }
注意:一定要加'/'開頭與結束哦。
|
新聞熱點
疑難解答