3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyElement extends DOMElement { public $id; public static $next = 0; function init() { $this->id = MyElement::$next++; echo "Initializing DOMElement #" . $this->id . ": " . $this->tagName . "\n"; return $this; } function __destruct() { echo "Destructing DOMElement #" . $this->id . ": " . $this->tagName . "\n"; } function info() { echo "Querying DOMElement #" . $this->id . ": " . $this->tagName . "\n"; } } function foo() { echo "Enter foo()\n"; $dom = new DOMDocument; $dom->registerNodeClass('DOMElement', 'MyElement'); $child = $dom->createElement('foo')->init(); $grandchild = $dom->createElement('bar')->init(); $greatgrandchild = $dom->createElement('fiz')->init(); $grandchild->appendChild($greatgrandchild); $child->appendChild($grandchild); $dom->appendChild($child); echo "Leave foo()\n"; return $grandchild; } function bar() { echo "Enter bar()\n"; $g = foo(); $fooList = $g->getElementsByTagName('foo'); foreach ($fooList as $foo) { $foo->info(); } echo "Leave bar()\n"; } echo "Enter main()\n"; bar(); echo "Leave main()\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AQaML
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   ECHO                                                     'Enter+main%28%29%0A'
   52     1        INIT_FCALL                                               'bar'
          2        DO_FCALL                                      0          
   53     3        ECHO                                                     'Leave+main%28%29%0A'
          4      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AQaML
function name:  foo
number of ops:  38
compiled vars:  !0 = $dom, !1 = $child, !2 = $grandchild, !3 = $greatgrandchild
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ECHO                                                     'Enter+foo%28%29%0A'
   25     1        NEW                                              $4      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $4
   26     4        INIT_METHOD_CALL                                         !0, 'registerNodeClass'
          5        SEND_VAL_EX                                              'DOMElement'
          6        SEND_VAL_EX                                              'MyElement'
          7        DO_FCALL                                      0          
   28     8        INIT_METHOD_CALL                                         !0, 'createElement'
          9        SEND_VAL_EX                                              'foo'
         10        DO_FCALL                                      0  $8      
         11        INIT_METHOD_CALL                                         $8, 'init'
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !1, $9
   29    14        INIT_METHOD_CALL                                         !0, 'createElement'
         15        SEND_VAL_EX                                              'bar'
         16        DO_FCALL                                      0  $11     
         17        INIT_METHOD_CALL                                         $11, 'init'
         18        DO_FCALL                                      0  $12     
         19        ASSIGN                                                   !2, $12
   30    20        INIT_METHOD_CALL                                         !0, 'createElement'
         21        SEND_VAL_EX                                              'fiz'
         22        DO_FCALL                                      0  $14     
         23        INIT_METHOD_CALL                                         $14, 'init'
         24        DO_FCALL                                      0  $15     
         25        ASSIGN                                                   !3, $15
   32    26        INIT_METHOD_CALL                                         !2, 'appendChild'
         27        SEND_VAR_EX                                              !3
         28        DO_FCALL                                      0          
   33    29        INIT_METHOD_CALL                                         !1, 'appendChild'
         30        SEND_VAR_EX                                              !2
         31        DO_FCALL                                      0          
   34    32        INIT_METHOD_CALL                                         !0, 'appendChild'
         33        SEND_VAR_EX                                              !1
         34        DO_FCALL                                      0          
   36    35        ECHO                                                     'Leave+foo%28%29%0A'
   37    36      > RETURN                                                   !2
   38    37*     > RETURN                                                   null

End of function foo

Function bar:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/AQaML
function name:  bar
number of ops:  16
compiled vars:  !0 = $g, !1 = $fooList, !2 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   ECHO                                                     'Enter+bar%28%29%0A'
   42     1        INIT_FCALL                                               'foo'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !0, $3
   44     4        INIT_METHOD_CALL                                         !0, 'getElementsByTagName'
          5        SEND_VAL_EX                                              'foo'
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !1, $5
   45     8      > FE_RESET_R                                       $7      !1, ->13
          9    > > FE_FETCH_R                                               $7, !2, ->13
   46    10    >   INIT_METHOD_CALL                                         !2, 'info'
         11        DO_FCALL                                      0          
   45    12      > JMP                                                      ->9
         13    >   FE_FREE                                                  $7
   48    14        ECHO                                                     'Leave+bar%28%29%0A'
   49    15      > RETURN                                                   null

End of function bar

Class MyElement:
Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AQaML
function name:  init
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   POST_INC_STATIC_PROP                             ~1      'next', 'MyElement'
          1        ASSIGN_OBJ                                               'id'
          2        OP_DATA                                                  ~1
    9     3        FETCH_OBJ_R                                      ~2      'id'
          4        CONCAT                                           ~3      'Initializing+DOMElement+%23', ~2
          5        CONCAT                                           ~4      ~3, '%3A+'
          6        FETCH_OBJ_R                                      ~5      'tagName'
          7        CONCAT                                           ~6      ~4, ~5
          8        CONCAT                                           ~7      ~6, '%0A'
          9        ECHO                                                     ~7
   11    10        FETCH_THIS                                       ~8      
         11      > RETURN                                                   ~8
   12    12*     > RETURN                                                   null

End of function init

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AQaML
function name:  __destruct
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'id'
          1        CONCAT                                           ~1      'Destructing+DOMElement+%23', ~0
          2        CONCAT                                           ~2      ~1, '%3A+'
          3        FETCH_OBJ_R                                      ~3      'tagName'
          4        CONCAT                                           ~4      ~2, ~3
          5        CONCAT                                           ~5      ~4, '%0A'
          6        ECHO                                                     ~5
   16     7      > RETURN                                                   null

End of function __destruct

Function info:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AQaML
function name:  info
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'id'
          1        CONCAT                                           ~1      'Querying+DOMElement+%23', ~0
          2        CONCAT                                           ~2      ~1, '%3A+'
          3        FETCH_OBJ_R                                      ~3      'tagName'
          4        CONCAT                                           ~4      ~2, ~3
          5        CONCAT                                           ~5      ~4, '%0A'
          6        ECHO                                                     ~5
   20     7      > RETURN                                                   null

End of function info

End of class MyElement.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
247.65 ms | 1407 KiB | 16 Q