split()函数在PHP7中报错

2019年6月15日22:25:37系统教程评论582

在新版本的php中已经不再支持split() ,如果你原来的程序中使用了split() ,在新版本的php中将会报错。文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

split() 不建议使用的原因:文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

PHP 5.3.0 之后的 regex, 希望使用 PCRE 的规格, POSIX Regex 都不建议使用了(统一 Regex, 避免规格太多?).文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

所以下述是不建议使用的 Function (POSIX), 与建议替换成的 Function (PCRE) 列表, 详可见: PHP: Differences from POSIX regex文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

POSIX → PCRE文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

ereg_replace() → preg_replace()文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

ereg() → preg_match()文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

eregi_replace() → preg_replace()文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

eregi() → preg_match()文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

split() → preg_split()文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

spliti() → preg_split()文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

sql_regcase() → No equivalent文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

PHP split() 替代方案文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

需要 regex 的 split, 可用 preg_split() 代替文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

不需要 regex, 只要要快速分割固定的字串, 可用 explode() 代替. (速度会比需要 regex 的快很多)文章源自堕落的鱼-https://www.duoluodeyu.com/2542.html

匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定