3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyDOMDocument extends DOMDocument { const HTML_EXPORT_CHILDREN = 1; public function saveHTML($node = null, $flags = 0) { $result = ''; if ($node === null) { $node = $this->documentElement; } if ($flags & self::HTML_EXPORT_CHILDREN) { foreach ($node->childNodes as $child) { $result .= parent::saveHTML($child); } } else { $result = parent::saveHTML($node); } return $result; } } $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->clone(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/amM4T
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
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN                                                   !0, '%3Cdiv%3Ehello%3C%2Fdiv%3E%0A%3Cdiv%3Eworld%3C%2Fdiv%3E'
   32     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
   33     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   35     7        INIT_METHOD_CALL                                         !1, 'createDocumentFragment'
          8        DO_FCALL                                      0  $10     
          9        ASSIGN                                                   !2, $10
   36    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
   38    17        FETCH_OBJ_R                                      ~15     !3, 'childNodes'
         18      > FE_RESET_R                                       $16     ~15, ->27
         19    > > FE_FETCH_R                                               $16, !4, ->27
   39    20    >   INIT_METHOD_CALL                                         !2, 'appendChild'
         21        INIT_METHOD_CALL                                         !4, 'clone'
         22        SEND_VAL_EX                                              <true>
         23        DO_FCALL                                      0  $17     
         24        SEND_VAR_NO_REF_EX                                       $17
         25        DO_FCALL                                      0          
   38    26      > JMP                                                      ->19
         27    >   FE_FREE                                                  $16
   42    28        INIT_METHOD_CALL                                         !1, 'saveHTML'
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0  $19     
         31        ECHO                                                     $19
   43    32        ECHO                                                     '%0A'
   44    33        ECHO                                                     '%0A'
   45    34        INIT_METHOD_CALL                                         !1, 'saveHTML'
         35        DO_FCALL                                      0  $20     
         36        ECHO                                                     $20
         37      > RETURN                                                   1

Class MyDOMDocument:
Function savehtml:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/amM4T
function name:  saveHTML
number of ops:  25
compiled vars:  !0 = $node, !1 = $flags, !2 = $result, !3 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      0
    9     2        ASSIGN                                                   !2, ''
   11     3        TYPE_CHECK                                    2          !0
          4      > JMPZ                                                     ~5, ->7
   12     5    >   FETCH_OBJ_R                                      ~6      'documentElement'
          6        ASSIGN                                                   !0, ~6
   15     7    >   BW_AND                                           ~8      !1, 1
          8      > JMPZ                                                     ~8, ->19
   16     9    >   FETCH_OBJ_R                                      ~9      !0, 'childNodes'
         10      > FE_RESET_R                                       $10     ~9, ->17
         11    > > FE_FETCH_R                                               $10, !3, ->17
   17    12    >   INIT_STATIC_METHOD_CALL                                  'saveHTML'
         13        SEND_VAR_EX                                              !3
         14        DO_FCALL                                      0  $11     
         15        ASSIGN_OP                                     8          !2, $11
   16    16      > JMP                                                      ->11
         17    >   FE_FREE                                                  $10
         18      > JMP                                                      ->23
   20    19    >   INIT_STATIC_METHOD_CALL                                  'saveHTML'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0  $13     
         22        ASSIGN                                                   !2, $13
   23    23    > > RETURN                                                   !2
   24    24*     > RETURN                                                   null

End of function savehtml

End of class MyDOMDocument.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.7 ms | 1399 KiB | 13 Q