3v4l.org

run code in 500+ PHP versions simultaneously
<?php $body = '<p><a href="#">link</a><a href="#">another</a><button>button</button><i>some text</i></p>'; $dom = new DOMDocument; @$dom->loadHTML("<?xml version='1.0' encoding='UTF-8'?><body>$body</body>"); $xpath = new DOMXPath($dom); $nodelist = $xpath->query('//a | //button'); // echo "Length is : " . $nodelist->length, PHP_EOL; foreach ($nodelist as $index => $node) { echo "Node $index is $node->nodeName" . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 35
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 35
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/umYVC
function name:  (null)
number of ops:  37
compiled vars:  !0 = $body, !1 = $dom, !2 = $xpath, !3 = $nodelist, !4 = $node, !5 = $index
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Cp%3E%3Ca+href%3D%22%23%22%3Elink%3C%2Fa%3E%3Ca+href%3D%22%23%22%3Eanother%3C%2Fa%3E%3Cbutton%3Ebutton%3C%2Fbutton%3E%3Ci%3Esome+text%3C%2Fi%3E%3C%2Fp%3E'
    4     1        NEW                                                  $7      'DOMDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $7
    5     4        BEGIN_SILENCE                                        ~10     
          5        INIT_METHOD_CALL                                             !1, 'loadHTML'
          6        ROPE_INIT                                         3  ~12     '%3C%3Fxml+version%3D%271.0%27+encoding%3D%27UTF-8%27%3F%3E%3Cbody%3E'
          7        ROPE_ADD                                          1  ~12     ~12, !0
          8        ROPE_END                                          2  ~11     ~12, '%3C%2Fbody%3E'
          9        SEND_VAL_EX                                                  ~11
         10        DO_FCALL                                          0          
         11        END_SILENCE                                                  ~10
    6    12        NEW                                                  $15     'DOMXPath'
         13        SEND_VAR_EX                                                  !1
         14        DO_FCALL                                          0          
         15        ASSIGN                                                       !2, $15
    7    16        INIT_METHOD_CALL                                             !2, 'query'
         17        SEND_VAL_EX                                                  '%2F%2Fa+%7C+%2F%2Fbutton'
         18        DO_FCALL                                          0  $18     
         19        ASSIGN                                                       !3, $18
   10    20        FETCH_OBJ_R                                          ~20     !3, 'length'
         21        CONCAT                                               ~21     'Length+is+%3A+', ~20
         22        ECHO                                                         ~21
         23        ECHO                                                         '%0A'
   11    24      > FE_RESET_R                                           $22     !3, ->35
         25    > > FE_FETCH_R                                           ~23     $22, !4, ->35
         26    >   ASSIGN                                                       !5, ~23
   12    27        ROPE_INIT                                         4  ~27     'Node+'
         28        ROPE_ADD                                          1  ~27     ~27, !5
         29        ROPE_ADD                                          2  ~27     ~27, '+is+'
         30        FETCH_OBJ_R                                          ~25     !4, 'nodeName'
         31        ROPE_END                                          3  ~26     ~27, ~25
         32        CONCAT                                               ~29     ~26, '%0A'
         33        ECHO                                                         ~29
   11    34      > JMP                                                          ->25
         35    >   FE_FREE                                                      $22
   13    36      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
206.5 ms | 1873 KiB | 12 Q