PHP Warning: preg_match() expects parameter 2 to be string, object...

发布网友

我来回答

3个回答

热心网友

int preg_match ( string $pattern, string $subject [, array &$matches[, int $flags = 0[, int $offset = 0 ]]] )

preg_match()函数的第二个参数必须为字符串,目前还不支持数组形式的匹配。

可如下解决

$result = $this->result;
foreach($result as $s){
preg_match("/^Resource/i", $s)

}

热心网友

第二个参数要是字符串,楼主的代码
$this -> result

这里应该出错了
你可以试试
echo $this -> result;

看看是什么,应该是这里有问题

热心网友

那可能要把第二个参数转换成字符串了

可能用到循环

热心网友

int preg_match ( string $pattern, string $subject [, array &$matches[, int $flags = 0[, int $offset = 0 ]]] )

preg_match()函数的第二个参数必须为字符串,目前还不支持数组形式的匹配。

可如下解决

$result = $this->result;
foreach($result as $s){
preg_match("/^Resource/i", $s)

}

热心网友

那可能要把第二个参数转换成字符串了

可能用到循环

热心网友

第二个参数要是字符串,楼主的代码
$this -> result

这里应该出错了
你可以试试
echo $this -> result;

看看是什么,应该是这里有问题

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com