3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = <<<HTML <img src="/image/fluffybunny.jpg" title="Harvey the bunny" alt="a cute little fluffy bunny" /> <img src='/image/pricklycactus.jpg' title='Roger the cactus' alt='a big green prickly cactus' /> <p>This is irrelevant text.</p> <img alt="an annoying white cockatoo" title="Polly the cockatoo" src="/image/noisycockatoo.jpg"> <img title=something src=somethingelse> HTML; libxml_use_internal_errors(true); // silences/forgives complaints from the parser (remove to see what is generated) $dom = new DOMDocument(); $dom->loadHTML($test); foreach ($dom->getElementsByTagName('img') as $i => $img) { echo "IMG#{$i}:\n"; echo "\tsrc = " , $img->getAttribute('src') , "\n"; echo "\ttitle = " , $img->getAttribute('title') , "\n"; echo "\talt = " , $img->getAttribute('alt') , "\n"; echo "---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 40
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 40
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/jsNCc
function name:  (null)
number of ops:  42
compiled vars:  !0 = $test, !1 = $dom, !2 = $img, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cimg+src%3D%22%2Fimage%2Ffluffybunny.jpg%22+title%3D%22Harvey+the+bunny%22+alt%3D%22a+cute+little+fluffy+bunny%22+%2F%3E%0A%3Cimg+src%3D%27%2Fimage%2Fpricklycactus.jpg%27+title%3D%27Roger+the+cactus%27+alt%3D%27a+big+green+prickly+cactus%27+%2F%3E%0A%3Cp%3EThis+is+irrelevant+text.%3C%2Fp%3E%0A%3Cimg+alt%3D%22an+annoying+white+cockatoo%22+title%3D%22Polly+the+cockatoo%22+src%3D%22%2Fimage%2Fnoisycockatoo.jpg%22%3E%0A%3Cimg+title%3Dsomething+src%3Dsomethingelse%3E'
   10     1        INIT_FCALL                                               'libxml_use_internal_errors'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                                 
   11     4        NEW                                              $6      'DOMDocument'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   12     7        INIT_METHOD_CALL                                         !1, 'loadHTML'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   13    10        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         11        SEND_VAL_EX                                              'img'
         12        DO_FCALL                                      0  $10     
         13      > FE_RESET_R                                       $11     $10, ->40
         14    > > FE_FETCH_R                                       ~12     $11, !2, ->40
         15    >   ASSIGN                                                   !3, ~12
   14    16        ROPE_INIT                                     3  ~15     'IMG%23'
         17        ROPE_ADD                                      1  ~15     ~15, !3
         18        ROPE_END                                      2  ~14     ~15, '%3A%0A'
         19        ECHO                                                     ~14
   15    20        ECHO                                                     '%09src+%3D+'
         21        INIT_METHOD_CALL                                         !2, 'getAttribute'
         22        SEND_VAL_EX                                              'src'
         23        DO_FCALL                                      0  $17     
         24        ECHO                                                     $17
         25        ECHO                                                     '%0A'
   16    26        ECHO                                                     '%09title+%3D+'
         27        INIT_METHOD_CALL                                         !2, 'getAttribute'
         28        SEND_VAL_EX                                              'title'
         29        DO_FCALL                                      0  $18     
         30        ECHO                                                     $18
         31        ECHO                                                     '%0A'
   17    32        ECHO                                                     '%09alt+%3D+'
         33        INIT_METHOD_CALL                                         !2, 'getAttribute'
         34        SEND_VAL_EX                                              'alt'
         35        DO_FCALL                                      0  $19     
         36        ECHO                                                     $19
         37        ECHO                                                     '%0A'
   18    38        ECHO                                                     '---%0A'
   13    39      > JMP                                                      ->14
         40    >   FE_FREE                                                  $11
   19    41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.04 ms | 1400 KiB | 15 Q