3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div>hello</div> <div>world</div> HTML; $doc = new DOMDocument; $doc->loadHTML($html); $frag = $doc->createDocumentFragment(); $body = $doc->getElementsByTagName('body')->item(0); foreach ($body->childNodes as $child) { $frag->appendChild($child->cloneNode(true)); } echo $doc->saveHTML($frag); echo PHP_EOL; echo PHP_EOL; echo $doc->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/ZEtrc
function name:  (null)
number of ops:  38
compiled vars:  !0 = $html, !1 = $doc, !2 = $frag, !3 = $body, !4 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv%3Ehello%3C%2Fdiv%3E%0A%3Cdiv%3Eworld%3C%2Fdiv%3E'
    8     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
    9     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   11     7        INIT_METHOD_CALL                                         !1, 'createDocumentFragment'
          8        DO_FCALL                                      0  $10     
          9        ASSIGN                                                   !2, $10
   12    10        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         11        SEND_VAL_EX                                              'body'
         12        DO_FCALL                                      0  $12     
         13        INIT_METHOD_CALL                                         $12, 'item'
         14        SEND_VAL_EX                                              0
         15        DO_FCALL                                      0  $13     
         16        ASSIGN                                                   !3, $13
   14    17        FETCH_OBJ_R                                      ~15     !3, 'childNodes'
         18      > FE_RESET_R                                       $16     ~15, ->27
         19    > > FE_FETCH_R                                               $16, !4, ->27
   15    20    >   INIT_METHOD_CALL                                         !2, 'appendChild'
         21        INIT_METHOD_CALL                                         !4, 'cloneNode'
         22        SEND_VAL_EX                                              <true>
         23        DO_FCALL                                      0  $17     
         24        SEND_VAR_NO_REF_EX                                       $17
         25        DO_FCALL                                      0          
   14    26      > JMP                                                      ->19
         27    >   FE_FREE                                                  $16
   18    28        INIT_METHOD_CALL                                         !1, 'saveHTML'
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0  $19     
         31        ECHO                                                     $19
   19    32        ECHO                                                     '%0A'
   20    33        ECHO                                                     '%0A'
   21    34        INIT_METHOD_CALL                                         !1, 'saveHTML'
         35        DO_FCALL                                      0  $20     
         36        ECHO                                                     $20
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.28 ms | 1395 KiB | 13 Q