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 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/KmUjg
function name:  (null)
number of ops:  20
compiled vars:  !0 = $html, !1 = $doc
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                                              $3      'MyDOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   33     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   34     7        INIT_METHOD_CALL                                         !1, 'saveHTML'
          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
         15        FETCH_CLASS_CONSTANT                             ~9      '%C2%A0MyDOMDocument', 'HTML_EXPORT_CHILDREN'
         16        SEND_VAL_EX                                              ~9
         17        DO_FCALL                                      0  $10     
         18        ECHO                                                     $10
         19      > 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/KmUjg
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:
153.8 ms | 1399 KiB | 13 Q