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; $flags = defined('LIBXML_SCHEMA_CREATE') ? LIBXML_SCHEMA_CREATE : 0; $document = new DOMDocument(); $document->loadXML($xml); var_dump($document->schemaValidateSource($schema, $flags)); $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 = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 46
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 46
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 46
Branch analysis from position: 28
Branch analysis from position: 46
filename:       /in/7cFpS
function name:  (null)
number of ops:  48
compiled vars:  !0 = $xml, !1 = $schema, !2 = $flags, !3 = $document, !4 = $xpath, !5 = $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      > JMPZ                                                     <true>, ->5
          3    >   QM_ASSIGN                                        ~8      1
          4      > JMP                                                      ->6
          5    >   QM_ASSIGN                                        ~8      0
          6    >   ASSIGN                                                   !2, ~8
   33     7        NEW                                              $10     'DOMDocument'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !3, $10
   34    10        INIT_METHOD_CALL                                         !3, 'loadXML'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
   35    13        INIT_FCALL                                               'var_dump'
         14        INIT_METHOD_CALL                                         !3, 'schemaValidateSource'
         15        SEND_VAR_EX                                              !1
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0  $14     
         18        SEND_VAR                                                 $14
         19        DO_ICALL                                                 
   37    20        NEW                                              $16     'DOMXPath'
         21        SEND_VAR_EX                                              !3
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !4, $16
   38    24        INIT_METHOD_CALL                                         !4, 'query'
         25        SEND_VAL_EX                                              '%2F%2Fitem'
         26        DO_FCALL                                      0  $19     
         27      > FE_RESET_R                                       $20     $19, ->46
         28    > > FE_FETCH_R                                               $20, !5, ->46
   39    29    >   INIT_METHOD_CALL                                         !5, 'getNodePath'
         30        DO_FCALL                                      0  $21     
         31        CONCAT                                           ~22     $21, '%0A'
   40    32        CONCAT                                           ~23     ~22, '++is-foo+%3A+'
         33        INIT_METHOD_CALL                                         !5, 'getAttribute'
         34        SEND_VAL_EX                                              'is-foo'
         35        DO_FCALL                                      0  $24     
         36        CONCAT                                           ~25     ~23, $24
         37        CONCAT                                           ~26     ~25, '%0A'
   41    38        CONCAT                                           ~27     ~26, '++is-bar+%3A+'
         39        INIT_METHOD_CALL                                         !5, 'getAttribute'
         40        SEND_VAL_EX                                              'is-bar'
         41        DO_FCALL                                      0  $28     
         42        CONCAT                                           ~29     ~27, $28
         43        CONCAT                                           ~30     ~29, '%0A'
         44        ECHO                                                     ~30
   38    45      > JMP                                                      ->28
         46    >   FE_FREE                                                  $20
   42    47      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.44 ms | 1392 KiB | 15 Q