3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = <<<HTML <a href="https://e...content-available-to-author-only...e.com/example1.jpg"> <a href="https://e...content-available-to-author-only...e.com/ストスト.jpg"> <a href="https://e...content-available-to-author-only...e.com/example3.jpg"> <a href="https://e...content-available-to-author-only...e.com/example3.bak"> HTML; $dom = new DomDocument(); $dom->loadHTML(mb_convert_encoding($input, 'HTML-ENTITIES', "UTF-8")); $anchors = $dom->getElementsByTagName("a"); $regex = '#^[\w,=/:.-]+\.(?:jpe?g|png|gif)$#iu'; foreach ($anchors as $anchor) { $res = $anchor->getAttribute("href"); if (preg_match($regex, $res)) { echo "Valid url: $res" . PHP_EOL; } else { echo "Invalid url: $res" . PHP_EOL; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 35
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 35
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 30
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/0hdkb
function name:  (null)
number of ops:  37
compiled vars:  !0 = $input, !1 = $dom, !2 = $anchors, !3 = $regex, !4 = $anchor, !5 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Ca+href%3D%22https%3A%2F%2Fe...content-available-to-author-only...e.com%2Fexample1.jpg%22%3E%0A%3Ca+href%3D%22https%3A%2F%2Fe...content-available-to-author-only...e.com%2F%E3%82%B9%E3%83%88%E3%82%B9%E3%83%88.jpg%22%3E%0A%3Ca+href%3D%22https%3A%2F%2Fe...content-available-to-author-only...e.com%2Fexample3.jpg%22%3E%0A%3Ca+href%3D%22https%3A%2F%2Fe...content-available-to-author-only...e.com%2Fexample3.bak%22%3E'
   10     1        NEW                                                  $7      'DomDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $7
   11     4        INIT_METHOD_CALL                                             !1, 'loadHTML'
          5        INIT_FCALL                                                   'mb_convert_encoding'
          6        SEND_VAR                                                     !0
          7        SEND_VAL                                                     'HTML-ENTITIES'
          8        SEND_VAL                                                     'UTF-8'
          9        DO_ICALL                                             $10     
         10        SEND_VAR_NO_REF_EX                                           $10
         11        DO_FCALL                                          0          
   13    12        INIT_METHOD_CALL                                             !1, 'getElementsByTagName'
         13        SEND_VAL_EX                                                  'a'
         14        DO_FCALL                                          0  $12     
         15        ASSIGN                                                       !2, $12
   14    16        ASSIGN                                                       !3, '%23%5E%5B%5Cw%2C%3D%2F%3A.-%5D%2B%5C.%28%3F%3Ajpe%3Fg%7Cpng%7Cgif%29%24%23iu'
   16    17      > FE_RESET_R                                           $15     !2, ->35
         18    > > FE_FETCH_R                                                   $15, !4, ->35
   17    19    >   INIT_METHOD_CALL                                             !4, 'getAttribute'
         20        SEND_VAL_EX                                                  'href'
         21        DO_FCALL                                          0  $16     
         22        ASSIGN                                                       !5, $16
   18    23        FRAMELESS_ICALL_2                preg_match          ~18     !3, !5
         24      > JMPZ                                                         ~18, ->30
   19    25    >   NOP                                                          
         26        FAST_CONCAT                                          ~19     'Valid+url%3A+', !5
         27        CONCAT                                               ~20     ~19, '%0A'
         28        ECHO                                                         ~20
   18    29      > JMP                                                          ->34
   21    30    >   NOP                                                          
         31        FAST_CONCAT                                          ~21     'Invalid+url%3A+', !5
         32        CONCAT                                               ~22     ~21, '%0A'
         33        ECHO                                                         ~22
   16    34    > > JMP                                                          ->18
         35    >   FE_FREE                                                      $15
   23    36      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.44 ms | 2204 KiB | 14 Q