3v4l.org

run code in 300+ PHP versions simultaneously
<?php $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; $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; $document = new DOMDocument(); $document->loadXML($xml); $document->schemaValidateSource($schema); $document->resolveExternals = true; $document->substituteEntities = true; $xpath = new DOMXPath($document); foreach ($xpath->query('//item') as $item) { echo $item->getNodePath() . PHP_EOL . ' is-foo : ' . ($item->getAttribute('is-foo') === 'true' ? 'true' : 'false') . PHP_EOL . ' is-bar : ' . ($item->getAttribute('is-bar') === 'true' ? 'true' : 'false') . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 51
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 51
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
Branch analysis from position: 46
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
filename:       /in/cXkpl
function name:  (null)
number of ops:  53
compiled vars:  !0 = $schema, !1 = $xml, !2 = $document, !3 = $xpath, !4 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%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'
   17     1        ASSIGN                                                   !1, '%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'
   31     2        NEW                                              $7      'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $7
   32     5        INIT_METHOD_CALL                                         !2, 'loadXML'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   33     8        INIT_METHOD_CALL                                         !2, 'schemaValidateSource'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
   34    11        ASSIGN_OBJ                                               !2, 'resolveExternals'
         12        OP_DATA                                                  <true>
   35    13        ASSIGN_OBJ                                               !2, 'substituteEntities'
         14        OP_DATA                                                  <true>
   37    15        NEW                                              $14     'DOMXPath'
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !3, $14
   38    19        INIT_METHOD_CALL                                         !3, 'query'
         20        SEND_VAL_EX                                              '%2F%2Fitem'
         21        DO_FCALL                                      0  $17     
         22      > FE_RESET_R                                       $18     $17, ->51
         23    > > FE_FETCH_R                                               $18, !4, ->51
   39    24    >   INIT_METHOD_CALL                                         !4, 'getNodePath'
         25        DO_FCALL                                      0  $19     
         26        CONCAT                                           ~20     $19, '%0A'
   40    27        CONCAT                                           ~21     ~20, '++is-foo+%3A+'
         28        INIT_METHOD_CALL                                         !4, 'getAttribute'
         29        SEND_VAL_EX                                              'is-foo'
         30        DO_FCALL                                      0  $22     
         31        IS_IDENTICAL                                             $22, 'true'
         32      > JMPZ                                                     ~23, ->35
         33    >   QM_ASSIGN                                        ~24     'true'
         34      > JMP                                                      ->36
         35    >   QM_ASSIGN                                        ~24     'false'
         36    >   CONCAT                                           ~25     ~21, ~24
         37        CONCAT                                           ~26     ~25, '%0A'
   41    38        CONCAT                                           ~27     ~26, '++is-bar+%3A+'
         39        INIT_METHOD_CALL                                         !4, 'getAttribute'
         40        SEND_VAL_EX                                              'is-bar'
         41        DO_FCALL                                      0  $28     
         42        IS_IDENTICAL                                             $28, 'true'
         43      > JMPZ                                                     ~29, ->46
         44    >   QM_ASSIGN                                        ~30     'true'
         45      > JMP                                                      ->47
         46    >   QM_ASSIGN                                        ~30     'false'
         47    >   CONCAT                                           ~31     ~27, ~30
         48        CONCAT                                           ~32     ~31, '%0A'
         49        ECHO                                                     ~32
   38    50      > JMP                                                      ->23
         51    >   FE_FREE                                                  $18
   42    52      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.8 ms | 1399 KiB | 13 Q