PHP:錯誤 Deprecated: Function split() is deprecated in … 解決辦法

來源:互聯網
上載者:User

本地測試的程式上傳到伺服器出現很多錯誤,Deprecated: Function split() is deprecated  
查了原因是因為PHP的版本不同所導致的,本身程式開發的時候用的是PHP5.2以下版本,而現在空間上用的是PHP5.3的版本,很多PHP函數已經過時不能用了,這裡的這個錯誤原因就是函數split()在 PHP5.3 中已經不建議使用了。

PHP5.3 split() 不建議使用的原因:
PHP 5.3.0 之後的regex, 希望使用PCRE 的規格, POSIX Regex 都不建議使用了(統一Regex, 避免規格太多?).

所以下述是不建議使用的Function (POSIX), 與建議替換成的Function (PCRE) 列表, 詳可見: PHP: Differences from POSIX regex

* POSIX → PCRE
* ereg_replace() → preg_replace()
* ereg() → preg_match()
* eregi_replace() → preg_replace()
* eregi() → preg_match()
* split() → preg_split()
* spliti() → preg_split()
* sql_regcase() → No equivalent

PHP split() 替代方案
* 需要regex 的split, 可用preg_split() 代替
* 不需要regex, 只要要快速分割固定的字串, 可用explode() 代替. (速度會比需要regex 的快很多)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.