3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doc = new DOMDocument; $doc->loadHTML('<html><body id="x"></body></html>'); $body = $doc->getElementById('x'); $div = $doc->createElement('div'); $div->setAttribute('id', 'y'); echo '0: ' . ( $doc->getElementById('y') ? $doc->getElementById('y')->tagName : 'null' ) . PHP_EOL; // div $body->appendChild($div); echo '1: ' . ( $doc->getElementById('y') ? $doc->getElementById('y')->tagName : 'null' ) . PHP_EOL; // div $div->setIdAttribute( 'id', true ); echo '2: ' . ( $doc->getElementById('y') ? $doc->getElementById('y')->tagName : 'null' ) . PHP_EOL; // null
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
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
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 63
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 63
Branch analysis from position: 57
Branch analysis from position: 63
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 45
Branch analysis from position: 39
Branch analysis from position: 45
filename:       /in/kk8iv
function name:  (null)
number of ops:  68
compiled vars:  !0 = $doc, !1 = $body, !2 = $div
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'DOMDocument'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    4     3        INIT_METHOD_CALL                                         !0, 'loadHTML'
          4        SEND_VAL_EX                                              '%3Chtml%3E%3Cbody+id%3D%22x%22%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        ASSIGN                                                   !1, $7
    6    10        INIT_METHOD_CALL                                         !0, 'createElement'
         11        SEND_VAL_EX                                              'div'
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !2, $9
    7    14        INIT_METHOD_CALL                                         !2, 'setAttribute'
         15        SEND_VAL_EX                                              'id'
         16        SEND_VAL_EX                                              'y'
         17        DO_FCALL                                      0          
    8    18        INIT_METHOD_CALL                                         !0, 'getElementById'
         19        SEND_VAL_EX                                              'y'
         20        DO_FCALL                                      0  $12     
         21      > JMPZ                                                     $12, ->28
         22    >   INIT_METHOD_CALL                                         !0, 'getElementById'
         23        SEND_VAL_EX                                              'y'
         24        DO_FCALL                                      0  $13     
         25        FETCH_OBJ_R                                      ~14     $13, 'tagName'
         26        QM_ASSIGN                                        ~15     ~14
         27      > JMP                                                      ->29
         28    >   QM_ASSIGN                                        ~15     'null'
         29    >   CONCAT                                           ~16     '0%3A+', ~15
         30        CONCAT                                           ~17     ~16, '%0A'
         31        ECHO                                                     ~17
    9    32        INIT_METHOD_CALL                                         !1, 'appendChild'
         33        SEND_VAR_EX                                              !2
         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        QM_ASSIGN                                        ~22     ~21
         44      > JMP                                                      ->46
         45    >   QM_ASSIGN                                        ~22     'null'
         46    >   CONCAT                                           ~23     '1%3A+', ~22
         47        CONCAT                                           ~24     ~23, '%0A'
         48        ECHO                                                     ~24
   11    49        INIT_METHOD_CALL                                         !2, 'setIdAttribute'
         50        SEND_VAL_EX                                              'id'
         51        SEND_VAL_EX                                              <true>
         52        DO_FCALL                                      0          
   12    53        INIT_METHOD_CALL                                         !0, 'getElementById'
         54        SEND_VAL_EX                                              'y'
         55        DO_FCALL                                      0  $26     
         56      > JMPZ                                                     $26, ->63
         57    >   INIT_METHOD_CALL                                         !0, 'getElementById'
         58        SEND_VAL_EX                                              'y'
         59        DO_FCALL                                      0  $27     
         60        FETCH_OBJ_R                                      ~28     $27, 'tagName'
         61        QM_ASSIGN                                        ~29     ~28
         62      > JMP                                                      ->64
         63    >   QM_ASSIGN                                        ~29     'null'
         64    >   CONCAT                                           ~30     '2%3A+', ~29
         65        CONCAT                                           ~31     ~30, '%0A'
         66        ECHO                                                     ~31
         67      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.94 ms | 1399 KiB | 13 Q