当我试图执行我的php代码时,我遇到了这个错误:
分析错误:语法错误,意外的'&'在第34行上的/opt/lamp/htdocs//app/engine.class.php中
private function setMatches($doc)
{
$strMatches = array();
$positions = $this->getPositions($doc);
foreach ($positions as $v)
{
$start = $v;
$end = 1;
$v++;
while ($end !== 0)
{
if (preg_match("/^<div/", &$doc[$v]))
$end++;
else if (preg_match("/^</div/", &$doc[$v]))
$end--;
$v++;
}
$end = $v - 1;
$strMatches[] = substr($doc, $start, $end - $start);
}
print_r($strMatches);
}
因此,在这里,我试图获得字符的地址,并将其作为字符串传递到preg-match函数中。我不明白,知道吗?
PHP中已删除引用调用时间传递。因此,我猜测您预挂起&
到$doc
的位置会生成语法错误。移除那些&
s。