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

End of function savehtml

End of class MyDOMDocument.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.65 ms | 1399 KiB | 13 Q