php5.3提示Function ereg() is deprecated Error問題解決方案,eregdeprecated_PHP教程

來源:互聯網
上載者:User

php5.3提示Function ereg() is deprecated Error問題解決方案,eregdeprecated


本文執行個體講述了php5.3提示Function ereg() is deprecated Error問題解決方案。分享給大家供大家參考。具體實現方法如下:

一、問題:

PHP 5.3 ereg() 無法正常使用,提示“Function ereg() is deprecated Error”是因為它長ereg 函數進行了升級處理,需要像preg_match使用/ /來規則了,當然也是php5.3把ereg給廢掉的節奏了。

PHP 5.3 ereg() 無法正常使用,提示“Function ereg() is deprecated Error”。
問題根源是php中有兩種正則表示方法,一個是posix,一個是perl,php6打算廢除posix的正則表示方法所以後來就加了個preg_match。此問題解決辦法很簡單,在ereg前加個過濾提示資訊符號即可:把ereg()變成@ereg()。這樣屏蔽了提示資訊,但根本問題還是沒有解決,php在5.2版本以前ereg都使用正常,在5.3以後,就要用preg_match來代替ereg。所以就需要變成這樣。

原來:ereg("^[0-9]*$",$page)變成:preg_match("/^[0-9]*$/",$page)

特別提醒:posix與perl的很明顯的表達區別就是是否加斜杠,所以與ereg相比,後者在正則的前後分別增加了兩個"/"符號,不能缺少。

例如:

改前:
複製代碼 代碼如下: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); // 進行過濾
}
二、解決方案:
找到代碼所在的檔案位置:
複製代碼 代碼如下: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); // 進行過濾
}

注意:一定要加'/'開頭與結束。此段參考:http://www.bkjia.com/article/38857.htm

補充:此問題在php5.2之前版本不會出現。

希望本文所述對大家的PHP程式設計有所協助。

http://www.bkjia.com/PHPjc/910600.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/910600.htmlTechArticlephp5.3提示Function ereg() is deprecated Error問題解決方案,eregdeprecated 本文執行個體講述了php5.3提示Function ereg() is deprecated Error問題解決方案。分享給大...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.