Подскажите, почему получаю ошибку на PHP 7.1
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)
Ругается на строку:
if (strpos(($childs[0])->nodeValue, $propName) !== false) Вот весь код
if (!function_exists('getPropValueFromHtmlByName')) {
function getPropValueFromHtmlByName($html, $propName) {
$doc = new DOMDocument();
$doc->loadHTML($html);
$tags = $doc->getElementsByTagName('li');
foreach ($tags as $tag) {
$childs = $tag->getElementsByTagName('span');
if (strpos(($childs[0])->nodeValue, $propName) !== false)
return ($childs[1])->nodeValue;
}
return '';
}
}
UPD: в $childs[0]
object(DOMElement)#617 (18) {
["tagName"]=>
string(4) "span"
["schemaTypeInfo"]=>
NULL
["nodeName"]=>
string(4) "span"
["nodeValue"]=>
string(12) "Availability"
["nodeType"]=>
int(1)
["parentNode"]=>
string(22) "(object value omitted)"
["childNodes"]=>
string(22) "(object value omitted)"
["firstChild"]=>
string(22) "(object value omitted)"
["lastChild"]=>
string(22) "(object value omitted)"
["previousSibling"]=>
string(22) "(object value omitted)"
["nextSibling"]=>
string(22) "(object value omitted)"
["attributes"]=>
string(22) "(object value omitted)"
["ownerDocument"]=>
string(22) "(object value omitted)"
["namespaceURI"]=>
NULL
["prefix"]=>
string(0) ""
["localName"]=>
string(4) "span"
["baseURI"]=>
NULL
["textContent"]=>
string(12) "Availability"
}
if (strpos($childs[0]->nodeValue, $propName) !== false)
.$childs[0]
? Распечатайте var_dump'ом