3v4l.org

run code in 300+ PHP versions simultaneously
<?php $enclosure = 'http://www.somesite.com/path1/path2/path3/somefile.150x150.png.jpg?size=150'; $pattern = '#(\.(png|jpg|jpeg|jpe|gif|tif|tiff|svg|ico|icon|x-icon)[\?]+)+#i'; $mime = ""; if (preg_match($pattern,$enclosure,$matches) > 0) $mime = 'image/'.end($matches); var_dump($matches); echo $mime;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/1NSdY
function name:  (null)
number of ops:  20
compiled vars:  !0 = $enclosure, !1 = $pattern, !2 = $mime, !3 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fwww.somesite.com%2Fpath1%2Fpath2%2Fpath3%2Fsomefile.150x150.png.jpg%3Fsize%3D150'
    4     1        ASSIGN                                                   !1, '%23%28%5C.%28png%7Cjpg%7Cjpeg%7Cjpe%7Cgif%7Ctif%7Ctiff%7Csvg%7Cico%7Cicon%7Cx-icon%29%5B%5C%3F%5D%2B%29%2B%23i'
    5     2        ASSIGN                                                   !2, ''
    6     3        INIT_FCALL                                               'preg_match'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !0
          6        SEND_REF                                                 !3
          7        DO_ICALL                                         $7      
          8        IS_SMALLER                                               0, $7
          9      > JMPZ                                                     ~8, ->15
         10    >   INIT_FCALL                                               'end'
         11        SEND_REF                                                 !3
         12        DO_ICALL                                         $9      
         13        CONCAT                                           ~10     'image%2F', $9
         14        ASSIGN                                                   !2, ~10
    8    15    >   INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                                 
    9    18        ECHO                                                     !2
         19      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.78 ms | 1386 KiB | 19 Q