3v4l.org

run code in 300+ PHP versions simultaneously
<?php $aDOM = new DOMDocument(); $aDOM->loadXML('<f2f:o xmlns:f2f=" http://friend2friend.net " xmlns:default="default"><default:i xmlns="default"><f2f:watch-me/></default:i></f2f:o>'); echo 'Initial DOM is '.$aDOM->saveXML().chr(13); $newNode= $aDOM->createElementNS(" http://friend2friend.net ", 'newnode'); $newNode->appendChild($aDOM->documentElement); echo 'Appending the document Element to f2f:newnode, it all looks OK: '.chr(13).$aDOM->saveXML($newNode).chr(13).chr(13); $aDOM->appendChild($newNode); echo 'But adding <f2f:newnode> back as the documentElement changes a namespace '.$aDOM->saveXML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/93fde
function name:  (null)
number of ops:  36
compiled vars:  !0 = $aDOM, !1 = $newNode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $2      'DOMDocument'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
    3     3        INIT_METHOD_CALL                                         !0, 'loadXML'
          4        SEND_VAL_EX                                              '%3Cf2f%3Ao+xmlns%3Af2f%3D%22+http%3A%2F%2Ffriend2friend.net+%22+xmlns%3Adefault%3D%22default%22%3E%3Cdefault%3Ai+xmlns%3D%22default%22%3E%3Cf2f%3Awatch-me%2F%3E%3C%2Fdefault%3Ai%3E%3C%2Ff2f%3Ao%3E'
          5        DO_FCALL                                      0          
    4     6        INIT_METHOD_CALL                                         !0, 'saveXML'
          7        DO_FCALL                                      0  $6      
          8        CONCAT                                           ~7      'Initial+DOM+is+', $6
          9        CONCAT                                           ~8      ~7, '%0D'
         10        ECHO                                                     ~8
    6    11        INIT_METHOD_CALL                                         !0, 'createElementNS'
         12        SEND_VAL_EX                                              '+http%3A%2F%2Ffriend2friend.net+'
         13        SEND_VAL_EX                                              'newnode'
         14        DO_FCALL                                      0  $9      
         15        ASSIGN                                                   !1, $9
    7    16        INIT_METHOD_CALL                                         !1, 'appendChild'
         17        CHECK_FUNC_ARG                                           
         18        FETCH_OBJ_FUNC_ARG                               $11     !0, 'documentElement'
         19        SEND_FUNC_ARG                                            $11
         20        DO_FCALL                                      0          
    8    21        INIT_METHOD_CALL                                         !0, 'saveXML'
         22        SEND_VAR_EX                                              !1
         23        DO_FCALL                                      0  $13     
         24        CONCAT                                           ~14     'Appending+the+document+Element+to+f2f%3Anewnode%2C+it+all+looks+OK%3A+%0D', $13
         25        CONCAT                                           ~15     ~14, '%0D'
         26        CONCAT                                           ~16     ~15, '%0D'
         27        ECHO                                                     ~16
   10    28        INIT_METHOD_CALL                                         !0, 'appendChild'
         29        SEND_VAR_EX                                              !1
         30        DO_FCALL                                      0          
   11    31        INIT_METHOD_CALL                                         !0, 'saveXML'
         32        DO_FCALL                                      0  $18     
         33        CONCAT                                           ~19     'But+adding+%3Cf2f%3Anewnode%3E+back+as+the+documentElement+changes+a+namespace+', $18
         34        ECHO                                                     ~19
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.99 ms | 1410 KiB | 13 Q