php錯誤提示:Deprecated: Function eregi() is deprecated
來源:程序員人生 發布時間:2014-01-09 04:45:51 閱讀次數:3071次
今天在利用一個正則時提示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);
- }
注意:一定要加'/'開頭與結束哦。
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈