“函数 split() 已弃用”在 PHP 中?
$stringText = "[TEST-1] test task 1 Created: 06/Apr/11 Updated: 06/Apr/11";
$splitArray = split(" ",$stringText);
已弃用:函数 split() 在 C:\wamp\www\RSS.php 第 27 行中已弃用
为什么会发生此错误?
$stringText = "[TEST-1] test task 1 Created: 06/Apr/11 Updated: 06/Apr/11";
$splitArray = split(" ",$stringText);
Deprecated: Function split() is deprecated in C:\wamp\www\RSS.php on line 27
Why this error happen ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
http://php.net/manual/en/function.split.php
来自手册
我猜你应该使用替代的
preg_split()
。或者,如果您不使用正则表达式,只需使用explode
http://php.net/manual/en/function.split.php
From the manual
I guess you're supposed to use the alternative
preg_split()
. Or if you're not using a regex, just useexplode
split 已替换为
explode
,请参阅 http://php.net/explode 了解更多信息。与 split 的工作方式相同,但 split 已“弃用”基本上意味着这是一个不应再使用的旧函数,并且不太可能出现在更高版本的 php 中。split has been replaced with
explode
, see http://php.net/explode for more information. Works the same as split, but split is 'deprecated' basically means that is a old function that shouldn't be used anymore, and is not likely to be in later versions of php.使用以下爆炸功能:
这是这种情况的标准解决方案。
其工作完美。
Use following explode function:
This is the standard solution for this case.
Its Perfectly working.
啊,docs 对此进行了说明。并且文档还说明了应该使用哪些函数来代替这个:
Ahh, the docs says about it. And the docs also say which functions should be used instead of this:
因为该功能已被弃用?您可以自定义 error_reporting 级别以不记录/显示折旧错误。但更谨慎的做法是纠正这个问题(IE 使用explode 来代替上面所做的简单分割。)
Because the function has been deprecated? You can customize the error_reporting level to not log / display the depreciated errors. But it would be more prudent to just correct the issue (IE use explode instead for the simple split you are doing above.)
您可以对旧代码使用此自定义函数:
You can use this custom function for old codes: