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)); 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 = 30, Position 2 = 38
Branch analysis from position: 30
2 jumps found. (Code = 78) Position 1 = 31, Position 2 = 38
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/q3VqZ
function name:  (null)
number of ops:  40
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        FETCH_OBJ_R                                      ~18     !1, 'documentElement'
         28        FETCH_OBJ_R                                      ~19     ~18, 'attributes'
         29      > FE_RESET_R                                       $20     ~19, ->38
         30    > > FE_FETCH_R                                               $20, !2, ->38
   20    31    >   INIT_FCALL                                               'var_dump'
         32        FETCH_OBJ_R                                      ~21     !2, 'nodeName'
         33        SEND_VAL                                                 ~21
         34        FETCH_OBJ_R                                      ~22     !2, 'nodeValue'
         35        SEND_VAL                                                 ~22
         36        DO_ICALL                                                 
   19    37      > JMP                                                      ->30
         38    >   FE_FREE                                                  $20
   21    39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.1 ms | 1015 KiB | 14 Q