3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rawxml = '<?xml version="1.0"?><root><field attr1="val1"><field attr1="val1"/></field></root>'; $rawxpath = "/root[1]/field[@attr1='val1']"; $results = array(); for ($i = 0; $i < 10000; $i++) { $xmlDocument = new DOMDocument(); $xmlDocument->loadXML($rawxml); $xp = new DOMXPath($xmlDocument); $xpr = $xp->evaluate($rawxpath, $xmlDocument->documentElement); if (isset($results[(string) $xpr->length])) $results[(string) $xpr->length]++; else $results[(string) $xpr->length] = 1; } foreach ($results as $matches => $count) printf("In %5d instances, found $matches match(es) for $rawxpath\n", $count);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 5
Branch analysis from position: 38
2 jumps found. (Code = 77) Position 1 = 39, Position 2 = 51
Branch analysis from position: 39
2 jumps found. (Code = 78) Position 1 = 40, Position 2 = 51
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 5
Branch analysis from position: 38
Branch analysis from position: 5
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 5
Branch analysis from position: 38
Branch analysis from position: 5
filename:       /in/uuU6t
function name:  (null)
number of ops:  53
compiled vars:  !0 = $rawxml, !1 = $rawxpath, !2 = $results, !3 = $i, !4 = $xmlDocument, !5 = $xp, !6 = $xpr, !7 = $count, !8 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22%3F%3E%3Croot%3E%3Cfield+attr1%3D%22val1%22%3E%3Cfield+attr1%3D%22val1%22%2F%3E%3C%2Ffield%3E%3C%2Froot%3E'
    3     1        ASSIGN                                                   !1, '%2Froot%5B1%5D%2Ffield%5B%40attr1%3D%27val1%27%5D'
    5     2        ASSIGN                                                   !2, <array>
    6     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->36
    7     5    >   NEW                                              $13     'DOMDocument'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !4, $13
    8     8        INIT_METHOD_CALL                                         !4, 'loadXML'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
    9    11        NEW                                              $17     'DOMXPath'
         12        SEND_VAR_EX                                              !4
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !5, $17
   10    15        INIT_METHOD_CALL                                         !5, 'evaluate'
         16        SEND_VAR_EX                                              !1
         17        CHECK_FUNC_ARG                                           
         18        FETCH_OBJ_FUNC_ARG                               $20     !4, 'documentElement'
         19        SEND_FUNC_ARG                                            $20
         20        DO_FCALL                                      0  $21     
         21        ASSIGN                                                   !6, $21
   12    22        FETCH_OBJ_R                                      ~23     !6, 'length'
         23        CAST                                          6  ~24     ~23
         24        ISSET_ISEMPTY_DIM_OBJ                         0          !2, ~24
         25      > JMPZ                                                     ~25, ->31
   13    26    >   FETCH_OBJ_R                                      ~26     !6, 'length'
         27        CAST                                          6  ~27     ~26
         28        FETCH_DIM_RW                                     $28     !2, ~27
         29        PRE_INC                                                  $28
         30      > JMP                                                      ->35
   15    31    >   FETCH_OBJ_R                                      ~30     !6, 'length'
         32        CAST                                          6  ~31     ~30
         33        ASSIGN_DIM                                               !2, ~31
         34        OP_DATA                                                  1
    6    35    >   PRE_INC                                                  !3
         36    >   IS_SMALLER                                               !3, 10000
         37      > JMPNZ                                                    ~34, ->5
   18    38    > > FE_RESET_R                                       $35     !2, ->51
         39    > > FE_FETCH_R                                       ~36     $35, !7, ->51
         40    >   ASSIGN                                                   !8, ~36
   19    41        INIT_FCALL                                               'printf'
         42        ROPE_INIT                                     5  ~39     'In+%255d+instances%2C+found+'
         43        ROPE_ADD                                      1  ~39     ~39, !8
         44        ROPE_ADD                                      2  ~39     ~39, '+match%28es%29+for+'
         45        ROPE_ADD                                      3  ~39     ~39, !1
         46        ROPE_END                                      4  ~38     ~39, '%0A'
         47        SEND_VAL                                                 ~38
         48        SEND_VAR                                                 !7
         49        DO_ICALL                                                 
   18    50      > JMP                                                      ->39
         51    >   FE_FREE                                                  $35
   19    52      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.64 ms | 1400 KiB | 15 Q