3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<!doctype html><html><body> <div class="item"> <span class="showcase-item-name showcase-item-brand">Name</span> <a href="/link/here">Click me</a> <span class="price-value">R$ 1,2.3</span> </div> </body></html> '; $dom = Dom\HTMLDocument::createFromString($html); foreach ($dom->querySelectorAll("div.item") as $item) { var_dump($item->querySelector("span.showcase-item-brand")->textContent); var_dump($item->querySelector("a[href]")->getAttribute("href")); var_dump($item->querySelector("span.price-value")->textContent); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 34
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 34
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/tKCCd
function name:  (null)
number of ops:  36
compiled vars:  !0 = $html, !1 = $dom, !2 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%21doctype+html%3E%3Chtml%3E%3Cbody%3E%0A++++%3Cdiv+class%3D%22item%22%3E%0A++++++++%3Cspan+class%3D%22showcase-item-name+showcase-item-brand%22%3EName%3C%2Fspan%3E%0A++++++++%3Ca+href%3D%22%2Flink%2Fhere%22%3EClick+me%3C%2Fa%3E%0A++++++++%3Cspan+class%3D%22price-value%22%3ER%24+1%2C2.3%3C%2Fspan%3E%0A++++%3C%2Fdiv%3E%0A%3C%2Fbody%3E%3C%2Fhtml%3E%0A'
   12     1        INIT_STATIC_METHOD_CALL                                  'Dom%5CHTMLDocument', 'createFromString'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   14     5        INIT_METHOD_CALL                                         !1, 'querySelectorAll'
          6        SEND_VAL_EX                                              'div.item'
          7        DO_FCALL                                      0  $6      
          8      > FE_RESET_R                                       $7      $6, ->34
          9    > > FE_FETCH_R                                               $7, !2, ->34
   15    10    >   INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !2, 'querySelector'
         12        SEND_VAL_EX                                              'span.showcase-item-brand'
         13        DO_FCALL                                      0  $8      
         14        FETCH_OBJ_R                                      ~9      $8, 'textContent'
         15        SEND_VAL                                                 ~9
         16        DO_ICALL                                                 
   16    17        INIT_FCALL                                               'var_dump'
         18        INIT_METHOD_CALL                                         !2, 'querySelector'
         19        SEND_VAL_EX                                              'a%5Bhref%5D'
         20        DO_FCALL                                      0  $11     
         21        INIT_METHOD_CALL                                         $11, 'getAttribute'
         22        SEND_VAL_EX                                              'href'
         23        DO_FCALL                                      0  $12     
         24        SEND_VAR                                                 $12
         25        DO_ICALL                                                 
   17    26        INIT_FCALL                                               'var_dump'
         27        INIT_METHOD_CALL                                         !2, 'querySelector'
         28        SEND_VAL_EX                                              'span.price-value'
         29        DO_FCALL                                      0  $14     
         30        FETCH_OBJ_R                                      ~15     $14, 'textContent'
         31        SEND_VAL                                                 ~15
         32        DO_ICALL                                                 
   14    33      > JMP                                                      ->9
         34    >   FE_FREE                                                  $7
   18    35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.88 ms | 1015 KiB | 14 Q