编程语言
首页 > 编程语言> > Phpmailer弃用eregi到preg_match转换?

Phpmailer弃用eregi到preg_match转换?

作者:互联网

我做了研究,转换为不使用已弃用的代码看起来很直接,但我对正则表达式的经验是有限的,我不太清楚这个问题的解决方案是什么.

这是原始行:

if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {

这在5.3.0中已弃用

所以我替换为:

if(preg_match('^(.+):([0-9]+)$/i', $hosts[$index], $hostinfo)) {

现在我明白了:

No ending delimiter ‘^’ found in…

我正在阅读的所有内容都表明我需要一个^和一个/来分隔我的功能.有任何想法吗?

解决方法:

整个字符串需要包装在/ / try:

if(preg_match('/^(.+):([0-9]+)$/i', $hosts[$index], $hostinfo)) {

标签:eregi,php,preg-match,phpmailer
来源: https://codeday.me/bug/20190726/1544556.html