3v4l.org

run code in 500+ PHP versions simultaneously
<?php class MyElement extends DOMElement { } $dom = new DOMDocument(); $e = new MyElement("e"); $dom->appendChild($e); // Gives MyElement echo get_class($dom->childNodes->item(0)) . "\n"; $e = null; // Gives DOMElement echo get_class($dom->childNodes->item(0)) . "\n"; $dom = new DOMDocument(); $dom->registerNodeClass('DOMElement', 'myElement'); $e = new MyElement("e"); $dom->appendChild($e); // Gives MyElement echo get_class($dom->childNodes->item(0)) . "\n"; $e = null; // Gives MyElement, because of registerNodeClass call. echo get_class($dom->childNodes->item(0)) . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WO0kP
function name:  (null)
number of ops:  55
compiled vars:  !0 = $dom, !1 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   NEW                                                  $2      'DOMDocument'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $2
    5     3        NEW                                                  $5      'MyElement'
          4        SEND_VAL_EX                                                  'e'
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !1, $5
    6     7        INIT_METHOD_CALL                                             !0, 'appendChild'
          8        SEND_VAR_EX                                                  !1
          9        DO_FCALL                                          0          
    8    10        FETCH_OBJ_R                                          ~9      !0, 'childNodes'
         11        INIT_METHOD_CALL                                             ~9, 'item'
         12        SEND_VAL_EX                                                  0
         13        DO_FCALL                                          0  $10     
         14        GET_CLASS                                            ~11     $10
         15        CONCAT                                               ~12     ~11, '%0A'
         16        ECHO                                                         ~12
    9    17        ASSIGN                                                       !1, null
   12    18        FETCH_OBJ_R                                          ~14     !0, 'childNodes'
         19        INIT_METHOD_CALL                                             ~14, 'item'
         20        SEND_VAL_EX                                                  0
         21        DO_FCALL                                          0  $15     
         22        GET_CLASS                                            ~16     $15
         23        CONCAT                                               ~17     ~16, '%0A'
         24        ECHO                                                         ~17
   14    25        NEW                                                  $18     'DOMDocument'
         26        DO_FCALL                                          0          
         27        ASSIGN                                                       !0, $18
   15    28        INIT_METHOD_CALL                                             !0, 'registerNodeClass'
         29        SEND_VAL_EX                                                  'DOMElement'
         30        SEND_VAL_EX                                                  'myElement'
         31        DO_FCALL                                          0          
   16    32        NEW                                                  $22     'MyElement'
         33        SEND_VAL_EX                                                  'e'
         34        DO_FCALL                                          0          
         35        ASSIGN                                                       !1, $22
   17    36        INIT_METHOD_CALL                                             !0, 'appendChild'
         37        SEND_VAR_EX                                                  !1
         38        DO_FCALL                                          0          
   19    39        FETCH_OBJ_R                                          ~26     !0, 'childNodes'
         40        INIT_METHOD_CALL                                             ~26, 'item'
         41        SEND_VAL_EX                                                  0
         42        DO_FCALL                                          0  $27     
         43        GET_CLASS                                            ~28     $27
         44        CONCAT                                               ~29     ~28, '%0A'
         45        ECHO                                                         ~29
   20    46        ASSIGN                                                       !1, null
   23    47        FETCH_OBJ_R                                          ~31     !0, 'childNodes'
         48        INIT_METHOD_CALL                                             ~31, 'item'
         49        SEND_VAL_EX                                                  0
         50        DO_FCALL                                          0  $32     
         51        GET_CLASS                                            ~33     $32
         52        CONCAT                                               ~34     ~33, '%0A'
         53        ECHO                                                         ~34
         54      > RETURN                                                       1

Class MyElement: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.51 ms | 3289 KiB | 13 Q