php錯(cuò)誤提示:Deprecated: Function eregi() is deprecated
來源:程序員人生 發(fā)布時(shí)間:2014-01-09 04:45:51 閱讀次數(shù):3075次
今天在利用一個(gè)正則時(shí)提示Deprecated: Function eregi() is deprecated in錯(cuò)誤了,后來查詢了一原因是我們php5.3,在5.3中己經(jīng)不支持eregi函數(shù)了,可以直接使用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);
- }
注意:一定要加'/'開頭與結(jié)束哦。
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈