3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 7.3.0rc3 - 7.3.0rc4
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.0.0 - 7.1.10, 7.2.0, 7.3.0alpha1 - 7.3.0beta1
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 7.1.20, 7.2.6
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 5.3.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.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.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.