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(); $dom->appendChild($child); $dom->appendChild($dom->createElement('bar')->init()); echo "Leave foo()\n"; return [$dom, $child]; } function bar() { echo "Enter bar()\n"; list($d, $c) = foo(); $fooList = $d->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/T1JaE
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   ECHO                                                     'Enter+main%28%29%0A'
   48     1        INIT_FCALL                                               'bar'
          2        DO_FCALL                                      0          
   49     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/T1JaE
function name:  foo
number of ops:  30
compiled vars:  !0 = $dom, !1 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ECHO                                                     'Enter+foo%28%29%0A'
   25     1        NEW                                              $2      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   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  $6      
         11        INIT_METHOD_CALL                                         $6, 'init'
         12        DO_FCALL                                      0  $7      
         13        ASSIGN                                                   !1, $7
   29    14        INIT_METHOD_CALL                                         !0, 'appendChild'
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0          
   30    17        INIT_METHOD_CALL                                         !0, 'appendChild'
         18        INIT_METHOD_CALL                                         !0, 'createElement'
         19        SEND_VAL_EX                                              'bar'
         20        DO_FCALL                                      0  $10     
         21        INIT_METHOD_CALL                                         $10, 'init'
         22        DO_FCALL                                      0  $11     
         23        SEND_VAR_NO_REF_EX                                       $11
         24        DO_FCALL                                      0          
   32    25        ECHO                                                     'Leave+foo%28%29%0A'
   33    26        INIT_ARRAY                                       ~13     !0
         27        ADD_ARRAY_ELEMENT                                ~13     !1
         28      > RETURN                                                   ~13
   34    29*     > RETURN                                                   null

End of function foo

Function bar:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/T1JaE
function name:  bar
number of ops:  20
compiled vars:  !0 = $d, !1 = $c, !2 = $fooList, !3 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   ECHO                                                     'Enter+bar%28%29%0A'
   38     1        INIT_FCALL                                               'foo'
          2        DO_FCALL                                      0  $4      
          3        FETCH_LIST_R                                     $5      $4, 0
          4        ASSIGN                                                   !0, $5
          5        FETCH_LIST_R                                     $7      $4, 1
          6        ASSIGN                                                   !1, $7
          7        FREE                                                     $4
   40     8        INIT_METHOD_CALL                                         !0, 'getElementsByTagName'
          9        SEND_VAL_EX                                              'foo'
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !2, $9
   41    12      > FE_RESET_R                                       $11     !2, ->17
         13    > > FE_FETCH_R                                               $11, !3, ->17
   42    14    >   INIT_METHOD_CALL                                         !3, 'info'
         15        DO_FCALL                                      0          
   41    16      > JMP                                                      ->13
         17    >   FE_FREE                                                  $11
   44    18        ECHO                                                     'Leave+bar%28%29%0A'
   45    19      > 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/T1JaE
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/T1JaE
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/T1JaE
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:
169.58 ms | 1407 KiB | 15 Q