3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests=[ 'Non-Images Only'=>'filename 1 (https://example.com/test.exe)', 'Mixed-Type'=>'filename 1 (https://example.com/test.pdf), filename 2 (https://example.com/cool_image.jpg), filename 3 (https://example.com/other-file.docx), filename 4 (https://example.com/nice_image.png)', 'No Files'=>'filename 1 (), filename 2 ()', 'Images-Only'=>'filename 1 (https://example.com/another.png), filename 2 (https://example.com/cool_image.jpg))']; $image_pattern='~\.(?:png|gif|jpe?g|bmp)\),?$~im'; $non_image_pattern='~\.(?:(?:png|gif|jpe?g|bmp)(*SKIP)(*FAIL)|[^.)]+)\),?$~im'; foreach($tests as $type=>$string){ echo "\t\tAssessing:\n---\n"; echo "$string\n---\n"; echo "Expecting: $type\n"; echo "Assessed as: "; $has_image=preg_match($image_pattern,$string); $has_non_image=preg_match($non_image_pattern,$string); if($has_image){ if($has_non_image){ echo "Mix of image and non-image files"; }else{ echo "Purely image files"; } }else{ if($has_non_image){ echo "Purely non-image files"; }else{ echo "No files recognized"; } } echo "\n----------------------------------------------------\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 37
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 37
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/KAjAL
function name:  (null)
number of ops:  39
compiled vars:  !0 = $tests, !1 = $image_pattern, !2 = $non_image_pattern, !3 = $string, !4 = $type, !5 = $has_image, !6 = $has_non_image
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   13     1        ASSIGN                                                   !1, '%7E%5C.%28%3F%3Apng%7Cgif%7Cjpe%3Fg%7Cbmp%29%5C%29%2C%3F%24%7Eim'
   14     2        ASSIGN                                                   !2, '%7E%5C.%28%3F%3A%28%3F%3Apng%7Cgif%7Cjpe%3Fg%7Cbmp%29%28%2ASKIP%29%28%2AFAIL%29%7C%5B%5E.%29%5D%2B%29%5C%29%2C%3F%24%7Eim'
   16     3      > FE_RESET_R                                       $10     !0, ->37
          4    > > FE_FETCH_R                                       ~11     $10, !3, ->37
          5    >   ASSIGN                                                   !4, ~11
   17     6        ECHO                                                     '%09%09Assessing%3A%0A---%0A'
   18     7        NOP                                                      
          8        FAST_CONCAT                                      ~13     !3, '%0A---%0A'
          9        ECHO                                                     ~13
   19    10        ROPE_INIT                                     3  ~15     'Expecting%3A+'
         11        ROPE_ADD                                      1  ~15     ~15, !4
         12        ROPE_END                                      2  ~14     ~15, '%0A'
         13        ECHO                                                     ~14
   20    14        ECHO                                                     'Assessed+as%3A+'
   21    15        INIT_FCALL                                               'preg_match'
         16        SEND_VAR                                                 !1
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                         $17     
         19        ASSIGN                                                   !5, $17
   22    20        INIT_FCALL                                               'preg_match'
         21        SEND_VAR                                                 !2
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                         $19     
         24        ASSIGN                                                   !6, $19
   23    25      > JMPZ                                                     !5, ->31
   24    26    > > JMPZ                                                     !6, ->29
   25    27    >   ECHO                                                     'Mix+of+image+and+non-image+files'
   24    28      > JMP                                                      ->30
   27    29    >   ECHO                                                     'Purely+image+files'
   23    30    > > JMP                                                      ->35
   30    31    > > JMPZ                                                     !6, ->34
   31    32    >   ECHO                                                     'Purely+non-image+files'
   30    33      > JMP                                                      ->35
   33    34    >   ECHO                                                     'No+files+recognized'
   36    35    >   ECHO                                                     '%0A----------------------------------------------------%0A'
   16    36      > JMP                                                      ->4
         37    >   FE_FREE                                                  $10
   37    38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.71 ms | 1010 KiB | 14 Q