3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<'XML' <?xml version="1.0"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:g="http://base.google.com/ns/1.0"> <title>The name of your data feed</title> <link href="http://www.example.com" rel="alternate" type="text/html" /> <updated>2006-06-11T18:30:02Z</updated> <author> <name>Google</name> </author> <id>tag:example.com,2006-06-11:/support/products</id> <entry> <title>Red wool sweater</title> <id>1a</id> <link href="http://www.example.com/item1-info-page.html" /> <summary>Comfortable and soft, this sweater will keep you warm on those cold winter nights.</summary> <updated>2005-10-13T18:30:02Z</updated> <g:image_link>http://www.google.com/images/google_sm.gif</g:image_link> <g:price>25</g:price> <g:condition>new</g:condition> </entry> </feed> XML; $file = 'data://text/plain;base64,'.urlencode($xml); $fileSize = strlen($xml); $readBytes = 0; $reader = new XMLReader; $reader->open($file); $dom = new DOMDocument(); $xpath = new DOMXpath($dom); $xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom'); $xpath->registerNamespace('gi', 'http://base.google.com/ns/1.0'); // look for the first entry element while ($reader->read() && $reader->localName !== 'entry') { continue; } // while you have an entry element while ($reader->localName === 'entry') { $node = $dom->importNode($reader->expand(), TRUE); var_dump( [ 'title' => $xpath->evaluate('string(atom:title)', $entry), 'summary' => $xpath->evaluate('string(atom:summary)', $entry), 'image-link' => $xpath->evaluate('string(gi:image_link)', $entry) ] ); $readBytes += strlen($reader->readOuterXml()); printf( 'Read %s of %s bytes, %d%%', $readBytes, $fileSize, round($readBytes * 100 / $fileSize) ); // move to the next entry sibling $reader->next('entry'); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 31
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 83
Branch analysis from position: 83
2 jumps found. (Code = 44) Position 1 = 86, Position 2 = 40
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 86, Position 2 = 40
Branch analysis from position: 86
Branch analysis from position: 40
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 38
filename:       /in/M6Ycl
function name:  (null)
number of ops:  87
compiled vars:  !0 = $xml, !1 = $file, !2 = $fileSize, !3 = $readBytes, !4 = $reader, !5 = $dom, !6 = $xpath, !7 = $node, !8 = $entry
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22%3F%3E%0A%3Cfeed+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2005%2FAtom%22%0Axmlns%3Ag%3D%22http%3A%2F%2Fbase.google.com%2Fns%2F1.0%22%3E%0A%3Ctitle%3EThe+name+of+your+data+feed%3C%2Ftitle%3E%0A%3Clink+href%3D%22http%3A%2F%2Fwww.example.com%22+rel%3D%22alternate%22+type%3D%22text%2Fhtml%22+%2F%3E%0A%3Cupdated%3E2006-06-11T18%3A30%3A02Z%3C%2Fupdated%3E%0A%3Cauthor%3E%0A%3Cname%3EGoogle%3C%2Fname%3E%0A%3C%2Fauthor%3E%0A%3Cid%3Etag%3Aexample.com%2C2006-06-11%3A%2Fsupport%2Fproducts%3C%2Fid%3E%0A%3Centry%3E%0A%3Ctitle%3ERed+wool+sweater%3C%2Ftitle%3E%0A%3Cid%3E1a%3C%2Fid%3E%0A%3Clink+href%3D%22http%3A%2F%2Fwww.example.com%2Fitem1-info-page.html%22+%2F%3E%0A%3Csummary%3EComfortable+and+soft%2C+this+sweater+will+keep+you+warm+on+those+cold+winter+nights.%3C%2Fsummary%3E%0A%3Cupdated%3E2005-10-13T18%3A30%3A02Z%3C%2Fupdated%3E+%0A%3Cg%3Aimage_link%3Ehttp%3A%2F%2Fwww.google.com%2Fimages%2Fgoogle_sm.gif%3C%2Fg%3Aimage_link%3E+%3Cg%3Aprice%3E25%3C%2Fg%3Aprice%3E+%3Cg%3Acondition%3Enew%3C%2Fg%3Acondition%3E%0A%3C%2Fentry%3E%0A%3C%2Ffeed%3E'
   25     1        INIT_FCALL                                               'urlencode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $10     
          4        CONCAT                                           ~11     'data%3A%2F%2Ftext%2Fplain%3Bbase64%2C', $10
          5        ASSIGN                                                   !1, ~11
   26     6        STRLEN                                           ~13     !0
          7        ASSIGN                                                   !2, ~13
   27     8        ASSIGN                                                   !3, 0
   29     9        NEW                                              $16     'XMLReader'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !4, $16
   30    12        INIT_METHOD_CALL                                         !4, 'open'
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
   32    15        NEW                                              $20     'DOMDocument'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !5, $20
   33    18        NEW                                              $23     'DOMXpath'
         19        SEND_VAR_EX                                              !5
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !6, $23
   34    22        INIT_METHOD_CALL                                         !6, 'registerNamespace'
         23        SEND_VAL_EX                                              'atom'
         24        SEND_VAL_EX                                              'http%3A%2F%2Fwww.w3.org%2F2005%2FAtom'
         25        DO_FCALL                                      0          
   35    26        INIT_METHOD_CALL                                         !6, 'registerNamespace'
         27        SEND_VAL_EX                                              'gi'
         28        SEND_VAL_EX                                              'http%3A%2F%2Fbase.google.com%2Fns%2F1.0'
         29        DO_FCALL                                      0          
   38    30      > JMP                                                      ->32
   39    31    > > JMP                                                      ->32
   38    32    >   INIT_METHOD_CALL                                         !4, 'read'
         33        DO_FCALL                                      0  $28     
         34      > JMPZ_EX                                          ~29     $28, ->38
         35    >   FETCH_OBJ_R                                      ~30     !4, 'localName'
         36        IS_NOT_IDENTICAL                                 ~31     ~30, 'entry'
         37        BOOL                                             ~29     ~31
         38    > > JMPNZ                                                    ~29, ->31
   43    39    > > JMP                                                      ->83
   44    40    >   INIT_METHOD_CALL                                         !5, 'importNode'
         41        INIT_METHOD_CALL                                         !4, 'expand'
         42        DO_FCALL                                      0  $32     
         43        SEND_VAR_NO_REF_EX                                       $32
         44        SEND_VAL_EX                                              <true>
         45        DO_FCALL                                      0  $33     
         46        ASSIGN                                                   !7, $33
   45    47        INIT_FCALL                                               'var_dump'
   47    48        INIT_METHOD_CALL                                         !6, 'evaluate'
         49        SEND_VAL_EX                                              'string%28atom%3Atitle%29'
         50        SEND_VAR_EX                                              !8
         51        DO_FCALL                                      0  $35     
         52        INIT_ARRAY                                       ~36     $35, 'title'
   48    53        INIT_METHOD_CALL                                         !6, 'evaluate'
         54        SEND_VAL_EX                                              'string%28atom%3Asummary%29'
         55        SEND_VAR_EX                                              !8
         56        DO_FCALL                                      0  $37     
         57        ADD_ARRAY_ELEMENT                                ~36     $37, 'summary'
   49    58        INIT_METHOD_CALL                                         !6, 'evaluate'
         59        SEND_VAL_EX                                              'string%28gi%3Aimage_link%29'
         60        SEND_VAR_EX                                              !8
         61        DO_FCALL                                      0  $38     
         62        ADD_ARRAY_ELEMENT                                ~36     $38, 'image-link'
         63        SEND_VAL                                                 ~36
         64        DO_ICALL                                                 
   53    65        INIT_METHOD_CALL                                         !4, 'readOuterXml'
         66        DO_FCALL                                      0  $40     
         67        STRLEN                                           ~41     $40
         68        ASSIGN_OP                                     1          !3, ~41
   54    69        INIT_FCALL                                               'printf'
   55    70        SEND_VAL                                                 'Read+%25s+of+%25s+bytes%2C+%25d%25%25'
   56    71        SEND_VAR                                                 !3
   57    72        SEND_VAR                                                 !2
   58    73        INIT_FCALL                                               'round'
         74        MUL                                              ~43     !3, 100
         75        DIV                                              ~44     ~43, !2
         76        SEND_VAL                                                 ~44
         77        DO_ICALL                                         $45     
         78        SEND_VAR                                                 $45
         79        DO_ICALL                                                 
   62    80        INIT_METHOD_CALL                                         !4, 'next'
         81        SEND_VAL_EX                                              'entry'
         82        DO_FCALL                                      0          
   43    83    >   FETCH_OBJ_R                                      ~48     !4, 'localName'
         84        IS_IDENTICAL                                             ~48, 'entry'
         85      > JMPNZ                                                    ~49, ->40
   63    86    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.94 ms | 1404 KiB | 21 Q