3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP $bad = array('html', 'FileType', 'IsColor', 'MimeType', 'SectionsFound', 'YCbCrPositioning', 1, 2); #$bad = array('html', 'FileType', 'IsColor', 'MimeType', 'SectionsFound', 'YCbCrPositioning'); $url = ''; $i = ''; $width = 0; $exif = array(); function input($str) { echo $str." "; return trim(fgets(STDIN)); } $url = 'http://upload.wikimedia.org/wikipedia/commons/2/23/Lake_mapourika_NZ.jpeg'; $file = basename($url).'.exif'; $f = fopen($file, 'w'); echo "Downloading ".$file."... "; if (is_file($url)) $i = file_get_contents($url); else { $c = curl_init($url); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); $i = curl_exec($c); if (!$i) { echo curl_error($c).PHP_EOL; die(); } } if (!$i) die("bad image input.".PHP_EOL); else echo "done.".PHP_EOL; fwrite($f, $i); fclose($f); if (($itype = exif_imagetype($file)) !== IMAGETYPE_JPEG or $itype === IMAGETYPE_TIFF_II or $itype == IMAGETYPE_TIFF_MM) { die("Image file type invalid for exif data.".PHP_EOL); } $exif = exif_read_data($file); if (!$exif) die("Image file contained no exif data.".PHP_EOL); array_walk_recursive($exif, function($v, $k) use (&$width) { if (strlen($k) > $width) $width = strlen($k); }); array_walk_recursive($exif, function($v, $k) use ($width, $bad) { if (preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $v) == '') { $hex = array(); $v = str_split($v); array_walk($v, function($v, $k) use (&$hex) { $hex[$k] = dechex(ord($v)); } ); $v = 'HEX[ '.implode(" ", $hex).' ]'; } else if (is_int($v)) $v = 'INT[ '.$v.' ]'; else $v = 'STRING[ '.$v.' ]'; $lim = 90; if (strlen($v) > $lim) $v = substr($v, 0, $lim-10).' ... '.substr($v, strlen($v)-5); if (preg_match('/Thumbnail\..+/i', $k) > 0) return; if (!in_array($k, $bad) and $v !== '') echo $k.str_repeat(' ', $width-strlen($k)).' => '.$v.PHP_EOL; }); unlink($file); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 60
Branch analysis from position: 58
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 60
2 jumps found. (Code = 47) Position 1 = 74, Position 2 = 76
Branch analysis from position: 74
2 jumps found. (Code = 47) Position 1 = 77, Position 2 = 79
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 80, Position 2 = 81
Branch analysis from position: 80
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 81
2 jumps found. (Code = 43) Position 1 = 87, Position 2 = 88
Branch analysis from position: 87
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 88
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 79
Branch analysis from position: 76
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 56
Branch analysis from position: 50
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 56
filename:       /in/8gGf7
function name:  (null)
number of ops:  105
compiled vars:  !0 = $bad, !1 = $url, !2 = $i, !3 = $width, !4 = $exif, !5 = $file, !6 = $f, !7 = $c, !8 = $itype
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, ''
    6     2        ASSIGN                                                   !2, ''
    7     3        ASSIGN                                                   !3, 0
    8     4        ASSIGN                                                   !4, <array>
   15     5        ASSIGN                                                   !1, 'http%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2F2%2F23%2FLake_mapourika_NZ.jpeg'
   17     6        INIT_FCALL                                               'basename'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $15     
          9        CONCAT                                           ~16     $15, '.exif'
         10        ASSIGN                                                   !5, ~16
   18    11        INIT_FCALL                                               'fopen'
         12        SEND_VAR                                                 !5
         13        SEND_VAL                                                 'w'
         14        DO_ICALL                                         $18     
         15        ASSIGN                                                   !6, $18
   20    16        CONCAT                                           ~20     'Downloading+', !5
         17        CONCAT                                           ~21     ~20, '...+'
         18        ECHO                                                     ~21
   22    19        INIT_FCALL                                               'is_file'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $22     
         22      > JMPZ                                                     $22, ->28
         23    >   INIT_FCALL                                               'file_get_contents'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $23     
         26        ASSIGN                                                   !2, $23
         27      > JMP                                                      ->56
   24    28    >   INIT_FCALL_BY_NAME                                       'curl_init'
         29        SEND_VAR_EX                                              !1
         30        DO_FCALL                                      0  $25     
         31        ASSIGN                                                   !7, $25
   25    32        INIT_FCALL_BY_NAME                                       'curl_setopt'
         33        SEND_VAR_EX                                              !7
         34        FETCH_CONSTANT                                   ~27     'CURLOPT_RETURNTRANSFER'
         35        SEND_VAL_EX                                              ~27
         36        SEND_VAL_EX                                              <true>
         37        DO_FCALL                                      0          
   26    38        INIT_FCALL_BY_NAME                                       'curl_setopt'
         39        SEND_VAR_EX                                              !7
         40        FETCH_CONSTANT                                   ~29     'CURLOPT_SSL_VERIFYPEER'
         41        SEND_VAL_EX                                              ~29
         42        SEND_VAL_EX                                              <false>
         43        DO_FCALL                                      0          
   27    44        INIT_FCALL_BY_NAME                                       'curl_exec'
         45        SEND_VAR_EX                                              !7
         46        DO_FCALL                                      0  $31     
         47        ASSIGN                                                   !2, $31
   28    48        BOOL_NOT                                         ~33     !2
         49      > JMPZ                                                     ~33, ->56
   29    50    >   INIT_FCALL_BY_NAME                                       'curl_error'
         51        SEND_VAR_EX                                              !7
         52        DO_FCALL                                      0  $34     
         53        CONCAT                                           ~35     $34, '%0A'
         54        ECHO                                                     ~35
   30    55      > EXIT                                                     
   34    56    >   BOOL_NOT                                         ~36     !2
         57      > JMPZ                                                     ~36, ->60
         58    > > EXIT                                                     'bad+image+input.%0A'
         59*       JMP                                                      ->61
   35    60    >   ECHO                                                     'done.%0A'
   37    61        INIT_FCALL                                               'fwrite'
         62        SEND_VAR                                                 !6
         63        SEND_VAR                                                 !2
         64        DO_ICALL                                                 
   38    65        INIT_FCALL                                               'fclose'
         66        SEND_VAR                                                 !6
         67        DO_ICALL                                                 
   40    68        INIT_FCALL_BY_NAME                                       'exif_imagetype'
         69        SEND_VAR_EX                                              !5
         70        DO_FCALL                                      0  $39     
         71        ASSIGN                                           ~40     !8, $39
         72        IS_NOT_IDENTICAL                                 ~41     ~40, 2
         73      > JMPNZ_EX                                         ~41     ~41, ->76
         74    >   IS_IDENTICAL                                     ~42     !8, 7
         75        BOOL                                             ~41     ~42
         76    > > JMPNZ_EX                                         ~41     ~41, ->79
         77    >   IS_EQUAL                                         ~43     !8, 8
         78        BOOL                                             ~41     ~43
         79    > > JMPZ                                                     ~41, ->81
   41    80    > > EXIT                                                     'Image+file+type+invalid+for+exif+data.%0A'
   44    81    >   INIT_FCALL_BY_NAME                                       'exif_read_data'
         82        SEND_VAR_EX                                              !5
         83        DO_FCALL                                      0  $44     
         84        ASSIGN                                                   !4, $44
   45    85        BOOL_NOT                                         ~46     !4
         86      > JMPZ                                                     ~46, ->88
         87    > > EXIT                                                     'Image+file+contained+no+exif+data.%0A'
   47    88    >   INIT_FCALL                                               'array_walk_recursive'
         89        SEND_REF                                                 !4
         90        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8gGf7%3A47%240'
         91        BIND_LEXICAL                                             ~47, !3
   49    92        SEND_VAL                                                 ~47
         93        DO_ICALL                                                 
   51    94        INIT_FCALL                                               'array_walk_recursive'
         95        SEND_REF                                                 !4
         96        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8gGf7%3A51%241'
         97        BIND_LEXICAL                                             ~49, !3
         98        BIND_LEXICAL                                             ~49, !0
   70    99        SEND_VAL                                                 ~49
        100        DO_ICALL                                                 
   72   101        INIT_FCALL                                               'unlink'
        102        SEND_VAR                                                 !5
        103        DO_ICALL                                                 
   74   104      > RETURN                                                   1

Function input:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8gGf7
function name:  input
number of ops:  12
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        CONCAT                                           ~1      !0, '+'
          2        ECHO                                                     ~1
   12     3        INIT_FCALL                                               'trim'
          4        INIT_FCALL                                               'fgets'
          5        FETCH_CONSTANT                                   ~2      'STDIN'
          6        SEND_VAL                                                 ~2
          7        DO_ICALL                                         $3      
          8        SEND_VAR                                                 $3
          9        DO_ICALL                                         $4      
         10      > RETURN                                                   $4
   13    11*     > RETURN                                                   null

End of function input

Function %00%7Bclosure%7D%2Fin%2F8gGf7%3A47%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/8gGf7
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $v, !1 = $k, !2 = $width
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   48     3        STRLEN                                           ~3      !1
          4        IS_SMALLER                                               !2, ~3
          5      > JMPZ                                                     ~4, ->8
          6    >   STRLEN                                           ~5      !1
          7        ASSIGN                                                   !2, ~5
   49     8    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8gGf7%3A47%240

Function %00%7Bclosure%7D%2Fin%2F8gGf7%3A51%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 30
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 58
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 65
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
2 jumps found. (Code = 46) Position 1 = 71, Position 2 = 73
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 85
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 85
Branch analysis from position: 73
Branch analysis from position: 58
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 36
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 58
Branch analysis from position: 43
Branch analysis from position: 58
filename:       /in/8gGf7
function name:  {closure}
number of ops:  86
compiled vars:  !0 = $v, !1 = $k, !2 = $width, !3 = $bad, !4 = $hex, !5 = $lim
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   52     4        INIT_FCALL                                               'preg_replace'
          5        SEND_VAL                                                 '%2F%5B%5Cx00-%5Cx1F%5Cx80-%5CxFF%5D%2F'
          6        SEND_VAL                                                 ''
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $6      
          9        IS_EQUAL                                                 $6, ''
         10      > JMPZ                                                     ~7, ->30
   53    11    >   ASSIGN                                                   !4, <array>
   54    12        INIT_FCALL                                               'str_split'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !0, $9
   55    16        INIT_FCALL                                               'array_walk'
         17        SEND_REF                                                 !0
   56    18        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8gGf7%3A56%242'
         19        BIND_LEXICAL                                             ~11, !4
   58    20        SEND_VAL                                                 ~11
         21        DO_ICALL                                                 
   60    22        INIT_FCALL                                               'implode'
         23        SEND_VAL                                                 '+'
         24        SEND_VAR                                                 !4
         25        DO_ICALL                                         $13     
         26        CONCAT                                           ~14     'HEX%5B+', $13
         27        CONCAT                                           ~15     ~14, '+%5D'
         28        ASSIGN                                                   !0, ~15
         29      > JMP                                                      ->39
   62    30    >   TYPE_CHECK                                   16          !0
         31      > JMPZ                                                     ~17, ->36
         32    >   CONCAT                                           ~18     'INT%5B+', !0
         33        CONCAT                                           ~19     ~18, '+%5D'
         34        ASSIGN                                                   !0, ~19
         35      > JMP                                                      ->39
   63    36    >   CONCAT                                           ~21     'STRING%5B+', !0
         37        CONCAT                                           ~22     ~21, '+%5D'
         38        ASSIGN                                                   !0, ~22
   65    39    >   ASSIGN                                                   !5, 90
   66    40        STRLEN                                           ~25     !0
         41        IS_SMALLER                                               !5, ~25
         42      > JMPZ                                                     ~26, ->58
         43    >   INIT_FCALL                                               'substr'
         44        SEND_VAR                                                 !0
         45        SEND_VAL                                                 0
         46        SUB                                              ~27     !5, 10
         47        SEND_VAL                                                 ~27
         48        DO_ICALL                                         $28     
         49        CONCAT                                           ~29     $28, '+...+'
         50        INIT_FCALL                                               'substr'
         51        SEND_VAR                                                 !0
         52        STRLEN                                           ~30     !0
         53        SUB                                              ~31     ~30, 5
         54        SEND_VAL                                                 ~31
         55        DO_ICALL                                         $32     
         56        CONCAT                                           ~33     ~29, $32
         57        ASSIGN                                                   !0, ~33
   68    58    >   INIT_FCALL                                               'preg_match'
         59        SEND_VAL                                                 '%2FThumbnail%5C..%2B%2Fi'
         60        SEND_VAR                                                 !1
         61        DO_ICALL                                         $35     
         62        IS_SMALLER                                               0, $35
         63      > JMPZ                                                     ~36, ->65
         64    > > RETURN                                                   null
   69    65    >   INIT_FCALL                                               'in_array'
         66        SEND_VAR                                                 !1
         67        SEND_VAR                                                 !3
         68        DO_ICALL                                         $37     
         69        BOOL_NOT                                         ~38     $37
         70      > JMPZ_EX                                          ~38     ~38, ->73
         71    >   IS_NOT_IDENTICAL                                 ~39     !0, ''
         72        BOOL                                             ~38     ~39
         73    > > JMPZ                                                     ~38, ->85
         74    >   INIT_FCALL                                               'str_repeat'
         75        SEND_VAL                                                 '+'
         76        STRLEN                                           ~40     !1
         77        SUB                                              ~41     !2, ~40
         78        SEND_VAL                                                 ~41
         79        DO_ICALL                                         $42     
         80        CONCAT                                           ~43     !1, $42
         81        CONCAT                                           ~44     ~43, '+%3D%3E+'
         82        CONCAT                                           ~45     ~44, !0
         83        CONCAT                                           ~46     ~45, '%0A'
         84        ECHO                                                     ~46
   70    85    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8gGf7%3A51%241

Function %00%7Bclosure%7D%2Fin%2F8gGf7%3A56%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8gGf7
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $v, !1 = $k, !2 = $hex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   57     3        INIT_FCALL                                               'dechex'
          4        INIT_FCALL                                               'ord'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                         $5      
          9        ASSIGN_DIM                                               !2, !1
         10        OP_DATA                                                  $5
   58    11      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8gGf7%3A56%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
214.52 ms | 1420 KiB | 53 Q