3v4l.org

run code in 500+ 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();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9gXDT
function name:  (null)
number of ops:  35
compiled vars:  !0 = $html, !1 = $document, !2 = $link, !3 = $htmldocument
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Chtml%3E%0A%3Chead%3E%0A%3Clink+rel%3D%22stylesheet%22+href%3D%22http%3A%2F%2F%5B%3A%3A1%5D%3A5173%2Fapp.css%22%2F%3E%0A%3Cscript+src%3D%22https%3A%2F%2F%5B%3A%3A1%5D%3A5173%2Fapp.js%22%3E%3C%2Fscript%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A%3Ca+href%3D%22http%3A%2F%2F%5B%3A%3A1%5D%22+data-custom%3D%22http%3A%2F%2F%5B%3A%3A1%5D%22%3Eanchor%3C%2Fa%3E%0A%3Cform+action%3D%22http%3A%2F%2F%5B%3A%3A1%5D%22%3E%3C%2Fform%3E%0A%3Cblockquote+cite%3D%22http%3A%2F%2F%5B%3A%3A1%5D%22%3E%3C%2Fblockquote%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   17     1        NEW                                                  $5      'DOMDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $5
   18     4        INIT_METHOD_CALL                                             !1, 'loadHTML'
          5        SEND_VAR_EX                                                  !0
          6        SEND_VAL_EX                                                  8192
          7        DO_FCALL                                          0          
   20     8        INIT_METHOD_CALL                                             !1, 'saveHTML'
          9        DO_FCALL                                          0  $9      
         10        ECHO                                                         $9
   22    11        ECHO                                                         '%0A'
   25    12        INIT_METHOD_CALL                                             !1, 'getElementsByTagName'
         13        SEND_VAL_EX                                                  'link'
         14        DO_FCALL                                          0  $10     
         15        INIT_METHOD_CALL                                             $10, 'item'
         16        SEND_VAL_EX                                                  0
         17        DO_FCALL                                          0  $11     
         18        INIT_METHOD_CALL                                             $11, 'getAttribute'
         19        SEND_VAL_EX                                                  'href'
         20        DO_FCALL                                          0  $12     
         21        ASSIGN                                                       !2, $12
   26    22        INIT_FCALL                                                   'var_dump'
         23        SEND_VAR                                                     !2
         24        DO_ICALL                                                     
   29    25        ECHO                                                         '%0A'
   32    26        INIT_STATIC_METHOD_CALL                                      'Dom%5CHTMLDocument', 'createFromString'
         27        SEND_VAR                                                     !0
         28        SEND_VAL                                                     8192
         29        DO_FCALL                                          0  $15     
         30        ASSIGN                                                       !3, $15
   33    31        INIT_METHOD_CALL                                             !3, 'saveHTML'
         32        DO_FCALL                                          0  $17     
         33        ECHO                                                         $17
         34      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.81 ms | 1186 KiB | 15 Q