3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<XML <item is-foo="false" is-bar="false"> <item is-bar="true"> <item> <item is-foo="true"> <item /> <item is-foo="true" /> </item> </item> <item is-foo="true" is-bar="true" /> </item> </item> XML; $schema = <<<SCHEMA <xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="item"> <xs:complexType> <xs:sequence> <xs:element ref="item" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> <xs:attribute name="is-foo" type="xs:boolean" default="true" use="optional" /> <xs:attribute name="is-bar" type="xs:boolean" default="false" use="optional" /> </xs:complexType> </xs:element> </xs:schema> SCHEMA; $document = new DOMDocument(); $document->loadXML($xml); var_dump($document->schemaValidateSource($schema, LIBXML_SCHEMA_CREATE)); $xpath = new DOMXPath($document); foreach ($xpath->query('//item') as $item) { echo $item->getNodePath() . PHP_EOL . ' is-foo : ' . $item->getAttribute('is-foo') . PHP_EOL . ' is-bar : ' . $item->getAttribute('is-bar') . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 41
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 41
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/vBRM8
function name:  (null)
number of ops:  43
compiled vars:  !0 = $xml, !1 = $schema, !2 = $document, !3 = $xpath, !4 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Citem+is-foo%3D%22false%22+is-bar%3D%22false%22%3E%0A++++%3Citem+is-bar%3D%22true%22%3E%0A++++++++%3Citem%3E%0A++++++++++++%3Citem+is-foo%3D%22true%22%3E%0A++++++++++++++++%3Citem+%2F%3E%0A++++++++++++++++%3Citem+is-foo%3D%22true%22+%2F%3E%0A++++++++++++%3C%2Fitem%3E%0A++++++++%3C%2Fitem%3E%0A++++++++%3Citem+is-foo%3D%22true%22+is-bar%3D%22true%22+%2F%3E%0A++++%3C%2Fitem%3E%0A%3C%2Fitem%3E'
   17     1        ASSIGN                                                   !1, '%3Cxs%3Aschema+elementFormDefault%3D%22qualified%22+xmlns%3Axs%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%3E%0A++++%3Cxs%3Aelement+name%3D%22item%22%3E%0A++++++++%3Cxs%3AcomplexType%3E%0A++++++++++++%3Cxs%3Asequence%3E%0A++++++++++++++++%3Cxs%3Aelement+ref%3D%22item%22+minOccurs%3D%220%22+maxOccurs%3D%22unbounded%22+%2F%3E%0A++++++++++++%3C%2Fxs%3Asequence%3E%0A++++++++++++%3Cxs%3Aattribute+name%3D%22is-foo%22+type%3D%22xs%3Aboolean%22+default%3D%22true%22+use%3D%22optional%22+%2F%3E%0A++++++++++++%3Cxs%3Aattribute+name%3D%22is-bar%22+type%3D%22xs%3Aboolean%22+default%3D%22false%22+use%3D%22optional%22+%2F%3E%0A++++++++%3C%2Fxs%3AcomplexType%3E%0A++++%3C%2Fxs%3Aelement%3E%0A%3C%2Fxs%3Aschema%3E'
   31     2        NEW                                              $7      'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $7
   32     5        INIT_METHOD_CALL                                         !2, 'loadXML'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
   33     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !2, 'schemaValidateSource'
         10        SEND_VAR_EX                                              !1
         11        SEND_VAL_EX                                              1
         12        DO_FCALL                                      0  $11     
         13        SEND_VAR                                                 $11
         14        DO_ICALL                                                 
   35    15        NEW                                              $13     'DOMXPath'
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !3, $13
   36    19        INIT_METHOD_CALL                                         !3, 'query'
         20        SEND_VAL_EX                                              '%2F%2Fitem'
         21        DO_FCALL                                      0  $16     
         22      > FE_RESET_R                                       $17     $16, ->41
         23    > > FE_FETCH_R                                               $17, !4, ->41
   37    24    >   INIT_METHOD_CALL                                         !4, 'getNodePath'
         25        DO_FCALL                                      0  $18     
         26        CONCAT                                           ~19     $18, '%0A'
   38    27        CONCAT                                           ~20     ~19, '++is-foo+%3A+'
         28        INIT_METHOD_CALL                                         !4, 'getAttribute'
         29        SEND_VAL_EX                                              'is-foo'
         30        DO_FCALL                                      0  $21     
         31        CONCAT                                           ~22     ~20, $21
         32        CONCAT                                           ~23     ~22, '%0A'
   39    33        CONCAT                                           ~24     ~23, '++is-bar+%3A+'
         34        INIT_METHOD_CALL                                         !4, 'getAttribute'
         35        SEND_VAL_EX                                              'is-bar'
         36        DO_FCALL                                      0  $25     
         37        CONCAT                                           ~26     ~24, $25
         38        CONCAT                                           ~27     ~26, '%0A'
         39        ECHO                                                     ~27
   36    40      > JMP                                                      ->23
         41    >   FE_FREE                                                  $17
   40    42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.48 ms | 1400 KiB | 15 Q