php7废弃了哪些,重建(替换)⼀些被PHP7废弃的函数
重建(替换)⼀些被 PHP7 废弃的函数
if(!function_exists(‘ereg’)) { function ereg($pattern, $subject, &$matches = []) { return preg_match(‘/’.$pattern.’/', $subject, $matches); } }php8兼容php7吗
if(!function_exists(‘eregi’)) { function eregi($pattern, $subject, &$matches = []) { return preg_match(‘/’.$pattern.’/i’, $subject, $matches); } }
if(!function_exists(‘ereg_replace’)) { function ereg_replace($pattern, $replacement, $string) { return
preg_replace(‘/’.$pattern.’/', $replacement, $string); } }
if(!function_exists(‘eregi_replace’)) { function eregi_replace($pattern, $replacement, $string) { return
preg_replace(‘/’.$pattern.’/i’, $replacement, $string); } }
if(!function_exists(‘split’)) { function split($pattern, $subject, $limit = -1) { return preg_split(‘/’.$pattern.’/', $subject, $limit); } }
if(!function_exists(‘spliti’)) { function spliti($pattern, $subject, $limit = -1) { return preg_split(‘/’.$pattern.’/i’, $subject, $limit); } }
温馨提⽰
有些地⽅替换函数中的 / 可能会报错,可以将 / 换成 ~,⽐如:
return preg_match(‘/’.$pattern.’/i’, $subject, $matches); 改为: return preg_match(‘~’.$pattern.’~i’, $subject, $matches);

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。