3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyElement extends DOMElement { } // #1 - okay $dom = new DOMDocument(); $e = new MyElement("e"); $dom->appendChild($e); echo get_class($dom->childNodes->item(0)) . "\n"; // #2 - wrong $dom = new DOMDocument(); $dom->appendChild(new MyElement("e")); echo get_class($dom->childNodes->item(0)) . "\n"; // #3 - wrong $dom = new DOMDocument(); $e = new MyElement("e"); $dom->appendChild($e); echo get_class($dom->childNodes->item(0)) . "\n"; $e = null; 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/RbvZX
function name:  (null)
number of ops:  59
compiled vars:  !0 = $dom, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   NEW                                              $2      'DOMDocument'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
    6     3        NEW                                              $5      'MyElement'
          4        SEND_VAL_EX                                              'e'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
    7     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
   11    17        NEW                                              $13     'DOMDocument'
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !0, $13
   12    20        INIT_METHOD_CALL                                         !0, 'appendChild'
         21        NEW                                              $16     'MyElement'
         22        SEND_VAL_EX                                              'e'
         23        DO_FCALL                                      0          
         24        SEND_VAR_NO_REF_EX                                       $16
         25        DO_FCALL                                      0          
   13    26        FETCH_OBJ_R                                      ~19     !0, 'childNodes'
         27        INIT_METHOD_CALL                                         ~19, 'item'
         28        SEND_VAL_EX                                              0
         29        DO_FCALL                                      0  $20     
         30        GET_CLASS                                        ~21     $20
         31        CONCAT                                           ~22     ~21, '%0A'
         32        ECHO                                                     ~22
   16    33        NEW                                              $23     'DOMDocument'
         34        DO_FCALL                                      0          
         35        ASSIGN                                                   !0, $23
   17    36        NEW                                              $26     'MyElement'
         37        SEND_VAL_EX                                              'e'
         38        DO_FCALL                                      0          
         39        ASSIGN                                                   !1, $26
   18    40        INIT_METHOD_CALL                                         !0, 'appendChild'
         41        SEND_VAR_EX                                              !1
         42        DO_FCALL                                      0          
   19    43        FETCH_OBJ_R                                      ~30     !0, 'childNodes'
         44        INIT_METHOD_CALL                                         ~30, 'item'
         45        SEND_VAL_EX                                              0
         46        DO_FCALL                                      0  $31     
         47        GET_CLASS                                        ~32     $31
         48        CONCAT                                           ~33     ~32, '%0A'
         49        ECHO                                                     ~33
   20    50        ASSIGN                                                   !1, null
   21    51        FETCH_OBJ_R                                      ~35     !0, 'childNodes'
         52        INIT_METHOD_CALL                                         ~35, 'item'
         53        SEND_VAL_EX                                              0
         54        DO_FCALL                                      0  $36     
         55        GET_CLASS                                        ~37     $36
         56        CONCAT                                           ~38     ~37, '%0A'
         57        ECHO                                                     ~38
         58      > RETURN                                                   1

Class MyElement: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.49 ms | 1399 KiB | 13 Q