3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * How to get attribute of node with namespace using SimpleXML? * * @link http://stackoverflow.com/q/6576773/367456 */ $buffer = '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:yt="http://gdata.youtube.com/schemas/2007"> <entry> <yt:duration seconds="1870" yt:seconds="0 in yt namespace" /> </entry> </feed>'; $xml = new SimpleXMLElement($buffer); if (!defined('LIBXML_DOTTED_VERSION')) { echo "PHP/LIBXML unsupported/too old."; return; } echo "ibxml version: ", LIBXML_DOTTED_VERSION, "\n"; $youtube = $xml; echo 'via attributes(): ', $youtube->entry->children('yt', TRUE)->duration->attributes()->seconds, "\n"; echo 'via array-access: ', $youtube->entry->children('yt', TRUE)->duration['seconds'], "\n"; echo 'via property : ', $youtube->entry->children('yt', TRUE)->duration->seconds, "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kR3vP
function name:  (null)
number of ops:  45
compiled vars:  !0 = $buffer, !1 = $xml, !2 = $youtube
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, '%3Cfeed+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2005%2FAtom%22+xmlns%3Ayt%3D%22http%3A%2F%2Fgdata.youtube.com%2Fschemas%2F2007%22%3E%0A++++%3Centry%3E%0A++++++++%3Cyt%3Aduration+seconds%3D%221870%22+yt%3Aseconds%3D%220+in+yt+namespace%22+%2F%3E%0A++++%3C%2Fentry%3E%0A%3C%2Ffeed%3E'
   13     1        NEW                                              $4      'SimpleXMLElement'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
   15     5      > JMPZ                                                     <false>, ->8
   16     6    >   ECHO                                                     'PHP%2FLIBXML+unsupported%2Ftoo+old.'
   17     7      > RETURN                                                   null
   20     8    >   ECHO                                                     'ibxml+version%3A+'
          9        ECHO                                                     '2.9.4'
         10        ECHO                                                     '%0A'
   22    11        ASSIGN                                                   !2, !1
   24    12        ECHO                                                     'via+attributes%28%29%3A+'
         13        FETCH_OBJ_R                                      ~8      !2, 'entry'
         14        INIT_METHOD_CALL                                         ~8, 'children'
         15        SEND_VAL_EX                                              'yt'
         16        SEND_VAL_EX                                              <true>
         17        DO_FCALL                                      0  $9      
         18        FETCH_OBJ_R                                      ~10     $9, 'duration'
         19        INIT_METHOD_CALL                                         ~10, 'attributes'
         20        DO_FCALL                                      0  $11     
         21        FETCH_OBJ_R                                      ~12     $11, 'seconds'
         22        ECHO                                                     ~12
         23        ECHO                                                     '%0A'
   25    24        ECHO                                                     'via+array-access%3A+'
         25        FETCH_OBJ_R                                      ~13     !2, 'entry'
         26        INIT_METHOD_CALL                                         ~13, 'children'
         27        SEND_VAL_EX                                              'yt'
         28        SEND_VAL_EX                                              <true>
         29        DO_FCALL                                      0  $14     
         30        FETCH_OBJ_R                                      ~15     $14, 'duration'
         31        FETCH_DIM_R                                      ~16     ~15, 'seconds'
         32        ECHO                                                     ~16
         33        ECHO                                                     '%0A'
   26    34        ECHO                                                     'via+property++++%3A+'
         35        FETCH_OBJ_R                                      ~17     !2, 'entry'
         36        INIT_METHOD_CALL                                         ~17, 'children'
         37        SEND_VAL_EX                                              'yt'
         38        SEND_VAL_EX                                              <true>
         39        DO_FCALL                                      0  $18     
         40        FETCH_OBJ_R                                      ~19     $18, 'duration'
         41        FETCH_OBJ_R                                      ~20     ~19, 'seconds'
         42        ECHO                                                     ~20
         43        ECHO                                                     '%0A'
         44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.42 ms | 1447 KiB | 13 Q