[DomCrawler] Fixed the Crawler::html() method for PHP versions earlier than 5.3.6.
Node argument was added to the DOMDocument::saveHTML() in PHP 5.3.6. See http://php.net/manual/en/domdocument.savehtml.php.
This commit is contained in:
parent
a27cbd9f45
commit
a4e3ebf385
@ -499,7 +499,15 @@ class Crawler extends \SplObjectStorage
|
|||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
foreach ($this->getNode(0)->childNodes as $child) {
|
foreach ($this->getNode(0)->childNodes as $child) {
|
||||||
|
if (version_compare(PHP_VERSION, '5.3.6', '>=')) {
|
||||||
|
// node parameter was added to the saveHTML() method in PHP 5.3.6
|
||||||
|
// @see http://php.net/manual/en/domdocument.savehtml.php
|
||||||
$html .= $child->ownerDocument->saveHTML($child);
|
$html .= $child->ownerDocument->saveHTML($child);
|
||||||
|
} else {
|
||||||
|
$document = new \DOMDocument('1.0', 'UTF-8');
|
||||||
|
$document->appendChild($document->importNode($child, true));
|
||||||
|
$html .= rtrim($document->saveHTML());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
|
Reference in New Issue
Block a user