3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<div id="demo"><h1>Recent Posts</h1></div>'; $dom = new DomDocument(); $dom->loadHTML($html); $node = $dom->getElementsByTagName('div')->item(0); $fragment = $dom->createDocumentFragment(); $fragment->appendXML('<ul><li>some items</li><li>some items</li><li>some items</li></ul>'); $node->appendChild($fragment); echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JrJan
function name:  (null)
number of ops:  27
compiled vars:  !0 = $html, !1 = $dom, !2 = $node, !3 = $fragment
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+id%3D%22demo%22%3E%3Ch1%3ERecent+Posts%3C%2Fh1%3E%3C%2Fdiv%3E'
    4     1        NEW                                              $5      'DomDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
    5     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
    6     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'div'
          9        DO_FCALL                                      0  $9      
         10        INIT_METHOD_CALL                                         $9, 'item'
         11        SEND_VAL_EX                                              0
         12        DO_FCALL                                      0  $10     
         13        ASSIGN                                                   !2, $10
    7    14        INIT_METHOD_CALL                                         !1, 'createDocumentFragment'
         15        DO_FCALL                                      0  $12     
         16        ASSIGN                                                   !3, $12
    8    17        INIT_METHOD_CALL                                         !3, 'appendXML'
         18        SEND_VAL_EX                                              '%3Cul%3E%3Cli%3Esome+items%3C%2Fli%3E%3Cli%3Esome+items%3C%2Fli%3E%3Cli%3Esome+items%3C%2Fli%3E%3C%2Ful%3E'
         19        DO_FCALL                                      0          
    9    20        INIT_METHOD_CALL                                         !2, 'appendChild'
         21        SEND_VAR_EX                                              !3
         22        DO_FCALL                                      0          
   10    23        INIT_METHOD_CALL                                         !1, 'saveHTML'
         24        DO_FCALL                                      0  $16     
         25        ECHO                                                     $16
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.74 ms | 982 KiB | 13 Q