3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doc = new DOMDocument; $doc->loadHTML('<html><body id="x"><div id="y"></div></body></html>'); $body = $doc->getElementById('x'); $div = $doc->getElementById('y'); $body->removeChild($div); echo '1: ' . ( $doc->getElementById('y') ? $doc->getElementById('y')->tagName : 'null' ) . PHP_EOL; $div->setIdAttribute( 'id', true ); echo '2: ' . ( $doc->getElementById('y') ? $doc->getElementById('y')->tagName : 'null' ) . PHP_EOL;
based on GXaLf
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 45
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 45
Branch analysis from position: 39
Branch analysis from position: 45
filename:       /in/UQYTG
function name:  (null)
number of ops:  50
compiled vars:  !0 = $doc, !1 = $body, !2 = $div
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NEW                                              $3      :95
         1        DO_FCALL                                      0          
         2        QM_ASSIGN                                                !0
   4     3        INIT_METHOD_CALL                                         !0, 'loadHTML'
         4        SEND_VAL_EX                                              '%3Chtml%3E%3Cbody+id%3D%22x%22%3E%3Cdiv+id%3D%22y%22%3E%3C%2Fdiv%3E%3C%2Fbody%3E%3C%2Fhtml%3E'
         5        DO_FCALL                                      0          
   5     6        INIT_METHOD_CALL                                         !0, 'getElementById'
         7        SEND_VAL_EX                                              'x'
         8        DO_FCALL                                      0  $7      
         9        QM_ASSIGN                                                !1
   6    10        INIT_METHOD_CALL                                         !0, 'getElementById'
        11        SEND_VAL_EX                                              'y'
        12        DO_FCALL                                      0  $9      
        13        QM_ASSIGN                                                !2
   7    14        INIT_METHOD_CALL                                         !1, 'removeChild'
        15        SEND_VAR_EX                                              !2
        16        DO_FCALL                                      0          
   8    17        INIT_METHOD_CALL                                         !0, 'getElementById'
        18        SEND_VAL_EX                                              'y'
        19        DO_FCALL                                      0  $12     
        20      > JMPZ                                                     $12, ->27
        21    >   INIT_METHOD_CALL                                         !0, 'getElementById'
        22        SEND_VAL_EX                                              'y'
        23        DO_FCALL                                      0  $13     
        24        FETCH_OBJ_R                                      ~14     $13, 'tagName'
        25        ASSIGN_BW_OR                                  0  ~15     ~14
        26      > JMP                                                      ->28
        27    >   ASSIGN_BW_OR                                  0  ~15     'null'
        28    >   CONCAT                                           ~16     '1%3A+', ~15
        29        CONCAT                                           ~17     ~16, '%0A'
        30        ASSIGN_OBJ                                               ~17
   9    31        INIT_METHOD_CALL                                         !2, 'setIdAttribute'
        32        SEND_VAL_EX                                              'id'
        33        SEND_VAL_EX                                              <true>
        34        DO_FCALL                                      0          
  10    35        INIT_METHOD_CALL                                         !0, 'getElementById'
        36        SEND_VAL_EX                                              'y'
        37        DO_FCALL                                      0  $19     
        38      > JMPZ                                                     $19, ->45
        39    >   INIT_METHOD_CALL                                         !0, 'getElementById'
        40        SEND_VAL_EX                                              'y'
        41        DO_FCALL                                      0  $20     
        42        FETCH_OBJ_R                                      ~21     $20, 'tagName'
        43        ASSIGN_BW_OR                                  0  ~22     ~21
        44      > JMP                                                      ->46
        45    >   ASSIGN_BW_OR                                  0  ~22     'null'
        46    >   CONCAT                                           ~23     '2%3A+', ~22
        47        CONCAT                                           ~24     ~23, '%0A'
        48        ASSIGN_OBJ                                               ~24
  11    49      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 7.4.0