Home  >  Article  >  Backend Development  >  php中“Deprecated: Function split() is deprecated in”错误解决办法

php中“Deprecated: Function split() is deprecated in”错误解决办法

WBOY
WBOYOriginal
2016-06-23 13:59:231338browse

出现这个错误的原因是:函数split()在 PHP5.3 中已经不建议使用了。

解决办法:用preg_split()函数替代split()。

举例说明:有一个字符串 $str="123@@describe"  ,要将其拆分为$id=123,$des="describe";

对于php5.3以后的版本,本人用的是php5.6,,测试代码如下

<?php // 分隔符可以是@@$date = "123@@describe";list($id, $des) = preg_split ('/@@/', $date);echo "id: $id; des: $des;<br />\n";?> 
输出结果如下图

    

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn