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); while ($body->firstChild) { $frag->appendChild($body->removeChild($body->firstChild)); } echo $doc->saveHTML($frag);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 18
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 18
Branch analysis from position: 28
Branch analysis from position: 18
filename:       /in/UmcPG
function name:  (null)
number of ops:  33
compiled vars:  !0 = $html, !1 = $doc, !2 = $frag, !3 = $body
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                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   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  $9      
          9        ASSIGN                                                   !2, $9
   36    10        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         11        SEND_VAL_EX                                              'body'
         12        DO_FCALL                                      0  $11     
         13        INIT_METHOD_CALL                                         $11, 'item'
         14        SEND_VAL_EX                                              0
         15        DO_FCALL                                      0  $12     
         16        ASSIGN                                                   !3, $12
   38    17      > JMP                                                      ->26
   39    18    >   INIT_METHOD_CALL                                         !2, 'appendChild'
         19        INIT_METHOD_CALL                                         !3, 'removeChild'
         20        CHECK_FUNC_ARG                                           
         21        FETCH_OBJ_FUNC_ARG                               $14     !3, 'firstChild'
         22        SEND_FUNC_ARG                                            $14
         23        DO_FCALL                                      0  $15     
         24        SEND_VAR_NO_REF_EX                                       $15
         25        DO_FCALL                                      0          
   38    26    >   FETCH_OBJ_R                                      ~17     !3, 'firstChild'
         27      > JMPNZ                                                    ~17, ->18
   41    28    >   INIT_METHOD_CALL                                         !1, 'saveHTML'
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0  $18     
         31        ECHO                                                     $18
         32      > 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/UmcPG
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:
148.83 ms | 1399 KiB | 13 Q