Deprecated: Function split() is deprecated in ... 解决办法

本文讨论了从PHP5.2升级到PHP5.3后遇到的split()函数弃用问题,并提供了两种替代方案:使用preg_split()进行正则表达式分割,或使用explode()实现快速字符串分割。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本地测试的程序上传到服务器出现很多错误,D eprecated: Function split() is deprecated   
查了原因是因为PHP的版本不 同所导致的 ,本身程序开发的时候用的是P HP 5.2以下版本,而现在空间上用的是PHP5.3的版本,很多PHP函数已 经过时不能用了 ,这里的这个错误原因就是函数 split() 在 PHP5.3 中已经不建议使用了。

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

所以下述是不建议使用的Function (POS IX), 与建议替换成的 Function (P CRE ) 列表, 详可见 PHP: Differences from POSIX regex

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


PHP split() 替代方案
* 需要regex 的split, 可用 preg_split ()  代替
* 不需要regex, 只要要快速分割固定的字串, 可用 explode()  代替. (速度会比需要regex 的快很多)
还是出现坏死终止模拟器和下列错误信息[Deprecation] SharedArrayBuffer will require cross-origin isolation as of M92, around July 2021. See https://developer.chrome.com/blog/enabling-shared-array-buffer/ for more details. [system] WeChatLib: 3.8.11 (2025.7.17 17:36:09) [system] No. of subpackages: 4 [system] LazyCodeLoading: true Lazy code loading is enabled. Only injecting required components. [wxobs] auto recording mode is not enabled in devtools. [体验分析] 为避免影响调试,开发者工具在非自定义启动模式下不会启动采集。详见 https://dev.weixin.qq.com/docs/analysis/sdk/debugging.html app.js:36 云环境初始化成功 [Perf] App.initCloud took 297ms onLaunch @ app.js:7 (anonymous) @ app.js:1 async function (async) (anonymous) @ appservice.app.js:5 [Perf] App.onLaunch took 314ms (anonymous) @ app.js:1 async function (async) (anonymous) @ appservice.app.js:5 [skyline] skyline 版本号: 1.4.0, 版本记录: 8f190450e6301587ce41e08afcaa983db4dc712e app.js:44 Worker初始化开始... wx.getSystemInfoSync is deprecated.Please use wx.getSystemSetting/wx.getAppAuthorizeSetting/wx.getDeviceInfo/wx.getWindowInfo/wx.getAppBaseInfo instead. initWorker @ app.js:47 (anonymous) @ app.js:16 listOnTimeout @ node:internal/timers:557 processTimers @ node:internal/timers:500 wx.getSystemInfoSync is deprecated.Please use wx.getSystemSetting/wx.getAppAuthorizeSetting/wx.getDeviceInfo/wx.getWindowInfo/wx.getAppBaseInfo instead. initWorker @ app.js:57 (anonymous) @ app.js:16 listOnTimeout @ node:internal/timers:557 processTimers @ node:internal/timers:500 app.js:63 当前环境不支持Worker
07-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值