3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<EOD <html> <head> <link rel="stylesheet" href="http://[::1]:5173/app.css"/> <script src="https://[::1]:5173/app.js"></script> </head> <body> <a href="http://[::1]" data-custom="http://[::1]">anchor</a> <form action="http://[::1]"></form> <blockquote cite="http://[::1]"></blockquote> </body> </html> EOD; $document = new DOMDocument(); $document->loadHTML($html, LIBXML_HTML_NOIMPLIED); print $document->saveHTML(); print "\n"; // internally it is represented correctly $link = $document->getElementsByTagName('link')->item(0)->getAttribute('href'); var_dump($link); print "\n"; // Dom\HTMLDocument works fine $htmldocument = Dom\HTMLDocument::createFromString($html, LIBXML_HTML_NOIMPLIED); print $htmldocument->saveHTML();
Output for 8.4.9 - 8.4.18, 8.5.2 - 8.5.3
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <link rel="stylesheet" href="http://%5B::1%5D:5173/app.css"> <script src="https://%5B::1%5D:5173/app.js"></script> </head> <body> <a href="http://%5B::1%5D" data-custom="http://[::1]">anchor</a> <form action="http://%5B::1%5D"></form> <blockquote cite="http://[::1]"></blockquote> </body> </html> string(25) "http://[::1]:5173/app.css" <html><head> <link rel="stylesheet" href="http://[::1]:5173/app.css"> <script src="https://[::1]:5173/app.js"></script> </head> <body> <a href="http://[::1]" data-custom="http://[::1]">anchor</a> <form action="http://[::1]"></form> <blockquote cite="http://[::1]"></blockquote> </body></html>
Output for 8.3.5 - 8.3.30
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <link rel="stylesheet" href="http://%5B::1%5D:5173/app.css"> <script src="https://%5B::1%5D:5173/app.js"></script> </head> <body> <a href="http://%5B::1%5D" data-custom="http://[::1]">anchor</a> <form action="http://%5B::1%5D"></form> <blockquote cite="http://[::1]"></blockquote> </body> </html> string(25) "http://[::1]:5173/app.css" Fatal error: Uncaught Error: Class "Dom\HTMLDocument" not found in /in/9gXDT:32 Stack trace: #0 {main} thrown in /in/9gXDT on line 32
Process exited with code 255.

preferences:
49.63 ms | 481 KiB | 5 Q