3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<XML <?xml version="1.0" ?> <root xmlns:foo="uri:foo" /> XML; $doc = new DOMDocument(); $doc->loadXML($xml); // These have special-case handling at the PHP level to redirect the lookup to the libxml namespace store // https://lxr.room11.org/xref/php-src%407.2/ext/dom/element.c#285 var_dump($doc->documentElement->hasAttribute('xmlns:foo')); var_dump($doc->documentElement->getAttribute('xmlns:foo')); // This directly retrieves the libxml attribute store, which does not include the namespace declarations // https://lxr.room11.org/xref/php-src%407.2/ext/dom/node.c#569 var_dump(count($doc->documentElement->attributes)); var_dump($doc->documentElement->attributes); foreach ($doc->documentElement->attributes as $attribute) { var_dump($attribute->nodeName, $attribute->nodeValue); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 35, Position 2 = 43
Branch analysis from position: 35
2 jumps found. (Code = 78) Position 1 = 36, Position 2 = 43
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
filename:       /in/UTcmn
function name:  (null)
number of ops:  45
compiled vars:  !0 = $xml, !1 = $doc, !2 = $attribute
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+%3F%3E%0A%3Croot+xmlns%3Afoo%3D%22uri%3Afoo%22+%2F%3E'
    8     1        NEW                                              $4      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
    9     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   13     7        INIT_FCALL                                               'var_dump'
          8        FETCH_OBJ_R                                      ~8      !1, 'documentElement'
          9        INIT_METHOD_CALL                                         ~8, 'hasAttribute'
         10        SEND_VAL_EX                                              'xmlns%3Afoo'
         11        DO_FCALL                                      0  $9      
         12        SEND_VAR                                                 $9
         13        DO_ICALL                                                 
   14    14        INIT_FCALL                                               'var_dump'
         15        FETCH_OBJ_R                                      ~11     !1, 'documentElement'
         16        INIT_METHOD_CALL                                         ~11, 'getAttribute'
         17        SEND_VAL_EX                                              'xmlns%3Afoo'
         18        DO_FCALL                                      0  $12     
         19        SEND_VAR                                                 $12
         20        DO_ICALL                                                 
   18    21        INIT_FCALL                                               'var_dump'
         22        FETCH_OBJ_R                                      ~14     !1, 'documentElement'
         23        FETCH_OBJ_R                                      ~15     ~14, 'attributes'
         24        COUNT                                            ~16     ~15
         25        SEND_VAL                                                 ~16
         26        DO_ICALL                                                 
   19    27        INIT_FCALL                                               'var_dump'
         28        FETCH_OBJ_R                                      ~18     !1, 'documentElement'
         29        FETCH_OBJ_R                                      ~19     ~18, 'attributes'
         30        SEND_VAL                                                 ~19
         31        DO_ICALL                                                 
   20    32        FETCH_OBJ_R                                      ~21     !1, 'documentElement'
         33        FETCH_OBJ_R                                      ~22     ~21, 'attributes'
         34      > FE_RESET_R                                       $23     ~22, ->43
         35    > > FE_FETCH_R                                               $23, !2, ->43
   21    36    >   INIT_FCALL                                               'var_dump'
         37        FETCH_OBJ_R                                      ~24     !2, 'nodeName'
         38        SEND_VAL                                                 ~24
         39        FETCH_OBJ_R                                      ~25     !2, 'nodeValue'
         40        SEND_VAL                                                 ~25
         41        DO_ICALL                                                 
   20    42      > JMP                                                      ->35
         43    >   FE_FREE                                                  $23
   22    44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.22 ms | 1015 KiB | 14 Q