3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dom = new DOMDocument; $file = <<<DATA <body> <div class="test"> <p> <img src="loading.gif" data-src="https://test.com/images/images/120/1313131313232.jpg" alt="test" /> </p> <img src="loading.gif" data-src="https://test.com/images/images/120/1313131313232.jpg" alt="test" /> </div> <div class="test"> This is text <img src="loading.gif" data-src="https://test.com/images/images/120/1313131313232.jpg" alt="test" /> </div> <div> <img src="loading.gif" data-src="https://test.com/images/images/120/1313131313232.jpg" alt="test" /> </div> </body> DATA; @$dom->loadHTML($file); $xpath = new DOMXPath($dom); $divs = $xpath->query('//div[@class="test"]'); foreach ($divs as $key => $div) { echo $div->textContent . PHP_EOL; foreach ($div->getElementsByTagName("img") as $img) { if ($img->getAttribute('alt') === 'test') { echo $img->getAttribute('data-src') . PHP_EOL; } } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 41
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 41
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 39
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 39
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 38
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 38
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 39
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/B8pic
function name:  (null)
number of ops:  43
compiled vars:  !0 = $dom, !1 = $file, !2 = $xpath, !3 = $divs, !4 = $div, !5 = $key, !6 = $img
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $7      'DOMDocument'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $7
    4     3        ASSIGN                                                   !1, '%3Cbody%3E%0A%3Cdiv+class%3D%22test%22%3E%0A++++%3Cp%3E%0A++++++++%3Cimg+src%3D%22loading.gif%22+data-src%3D%22https%3A%2F%2Ftest.com%2Fimages%2Fimages%2F120%2F1313131313232.jpg%22+alt%3D%22test%22+%2F%3E%0A++++%3C%2Fp%3E%0A++++%3Cimg+src%3D%22loading.gif%22+data-src%3D%22https%3A%2F%2Ftest.com%2Fimages%2Fimages%2F120%2F1313131313232.jpg%22+alt%3D%22test%22+%2F%3E%0A%3C%2Fdiv%3E%0A%3Cdiv+class%3D%22test%22%3E%0AThis+is+text%0A++++%3Cimg+src%3D%22loading.gif%22+data-src%3D%22https%3A%2F%2Ftest.com%2Fimages%2Fimages%2F120%2F1313131313232.jpg%22+alt%3D%22test%22+%2F%3E%0A%3C%2Fdiv%3E%0A%3Cdiv%3E%0A++++%3Cimg+src%3D%22loading.gif%22+data-src%3D%22https%3A%2F%2Ftest.com%2Fimages%2Fimages%2F120%2F1313131313232.jpg%22+alt%3D%22test%22+%2F%3E%0A%3C%2Fdiv%3E%0A%3C%2Fbody%3E'
   22     4        BEGIN_SILENCE                                    ~11     
          5        INIT_METHOD_CALL                                         !0, 'loadHTML'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
          8        END_SILENCE                                              ~11
   23     9        NEW                                              $13     'DOMXPath'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !2, $13
   24    13        INIT_METHOD_CALL                                         !2, 'query'
         14        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40class%3D%22test%22%5D'
         15        DO_FCALL                                      0  $16     
         16        ASSIGN                                                   !3, $16
   25    17      > FE_RESET_R                                       $18     !3, ->41
         18    > > FE_FETCH_R                                       ~19     $18, !4, ->41
         19    >   ASSIGN                                                   !5, ~19
   26    20        FETCH_OBJ_R                                      ~21     !4, 'textContent'
         21        CONCAT                                           ~22     ~21, '%0A'
         22        ECHO                                                     ~22
   27    23        INIT_METHOD_CALL                                         !4, 'getElementsByTagName'
         24        SEND_VAL_EX                                              'img'
         25        DO_FCALL                                      0  $23     
         26      > FE_RESET_R                                       $24     $23, ->39
         27    > > FE_FETCH_R                                               $24, !6, ->39
   28    28    >   INIT_METHOD_CALL                                         !6, 'getAttribute'
         29        SEND_VAL_EX                                              'alt'
         30        DO_FCALL                                      0  $25     
         31        IS_IDENTICAL                                             $25, 'test'
         32      > JMPZ                                                     ~26, ->38
   29    33    >   INIT_METHOD_CALL                                         !6, 'getAttribute'
         34        SEND_VAL_EX                                              'data-src'
         35        DO_FCALL                                      0  $27     
         36        CONCAT                                           ~28     $27, '%0A'
         37        ECHO                                                     ~28
   27    38    > > JMP                                                      ->27
         39    >   FE_FREE                                                  $24
   25    40      > JMP                                                      ->18
         41    >   FE_FREE                                                  $18
   32    42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
291.66 ms | 1012 KiB | 13 Q