Erreur "Object of class DOMDocument could not be converted to string"
Bonjour à tous.
J'essaie d'utiliser preg_replace avec DomDocument mais mon code me renvoie l'erreur:
Citation:
Fatal error: Uncaught Error: Object of class DOMDocument could not be converted to string in C:\laragon\www\test3.php:78 Stack trace: #0 C:\laragon\www\test3.php(78): preg_replace('/\\ \\;|\\&rdq...', ' ', Object(DOMDocument)) #1 {main} thrown in C:\laragon\www\test3.php on line 9
Code:
1 2 3 4 5 6 7 8 9 10 11
| <?php
$url= "https://fr.wikipedia.org/wiki/Jos%C3%A9_Eduardo_dos_Santos";
libxml_use_internal_errors(true);
$parser = new DOMDocument();
$parser->loadHTMLFile($url);
$pageParsed = preg_replace('/\ \;|\&rdquo\;|\&ldquo\;|\&mdash\;/si', ' ', $parser);
$pageParsing = preg_replace('@<script[^>]*?>[\s\S]*?</script\s*>@si', ' ', $pageParsed);
$dom_page = preg_replace('@<style[^>]*?>[\s\S]*?</style>@si', ' ', $pageParsing); |
Aidez-moi à corriger mon code s'il vous plaît.