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); ?>
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: fopen(): open_basedir restriction in effect. File(Lake_mapourika_NZ.jpeg.exif) is not within the allowed path(s): (/tmp:/in:/etc) in /in/8gGf7 on line 18 Warning: fopen(Lake_mapourika_NZ.jpeg.exif): Failed to open stream: Operation not permitted in /in/8gGf7 on line 18 Downloading Lake_mapourika_NZ.jpeg.exif... Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/8gGf7:24 Stack trace: #0 {main} thrown in /in/8gGf7 on line 24
Process exited with code 255.
Output for 8.0.13
Warning: fopen(Lake_mapourika_NZ.jpeg.exif): Failed to open stream: Read-only file system in /in/8gGf7 on line 18 Downloading Lake_mapourika_NZ.jpeg.exif... Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/8gGf7:24 Stack trace: #0 {main} thrown in /in/8gGf7 on line 24
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26, 7.4.33
Warning: fopen(Lake_mapourika_NZ.jpeg.exif): failed to open stream: Read-only file system in /in/8gGf7 on line 18 Downloading Lake_mapourika_NZ.jpeg.exif... Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/8gGf7:24 Stack trace: #0 {main} thrown in /in/8gGf7 on line 24
Process exited with code 255.
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.32
Warning: fopen(): open_basedir restriction in effect. File(Lake_mapourika_NZ.jpeg.exif) is not within the allowed path(s): (/tmp:/in:/etc) in /in/8gGf7 on line 18 Warning: fopen(Lake_mapourika_NZ.jpeg.exif): failed to open stream: Operation not permitted in /in/8gGf7 on line 18 Downloading Lake_mapourika_NZ.jpeg.exif... Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/8gGf7:24 Stack trace: #0 {main} thrown in /in/8gGf7 on line 24
Process exited with code 255.
Output for 7.1.20
Warning: fopen(): open_basedir restriction in effect. File(Lake_mapourika_NZ.jpeg.exif) is not within the allowed path(s): (/tmp:/in) in /in/8gGf7 on line 18 Warning: fopen(Lake_mapourika_NZ.jpeg.exif): failed to open stream: Operation not permitted in /in/8gGf7 on line 18 Downloading Lake_mapourika_NZ.jpeg.exif... Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/8gGf7:24 Stack trace: #0 {main} thrown in /in/8gGf7 on line 24
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.10
Warning: fopen(Lake_mapourika_NZ.jpeg.exif): failed to open stream: Permission denied in /in/8gGf7 on line 18 Downloading Lake_mapourika_NZ.jpeg.exif... Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/8gGf7:24 Stack trace: #0 {main} thrown in /in/8gGf7 on line 24
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.26
Warning: fopen(Lake_mapourika_NZ.jpeg.exif): failed to open stream: Permission denied in /in/8gGf7 on line 18 Downloading Lake_mapourika_NZ.jpeg.exif... Fatal error: Call to undefined function curl_init() in /in/8gGf7 on line 24
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/8gGf7 on line 47
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/8gGf7 on line 47
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/8gGf7 on line 47
Process exited with code 255.

preferences:
232.53 ms | 401 KiB | 401 Q