3v4l.org

run code in 200+ PHP versions simultaneously
<?php $utfchar = chr(0xC3).chr(0x89); // U+009C in UTF-8 $csv = $utfchar."x".$utfchar."x\n"; $file = fopen('php://memory', 'w+'); fputs($file, $csv); rewind($file); $data = fgetcsv($file); for ($i = 0; $i < strlen($data[0]); $i++) { echo dechex(ord($data[0][$i])).' '; } echo "\n"; fclose($file); // expected: c3 89 78 c3 89 78 - "ÉxÉx" // actual: 78 c3 89 78 - "xÉx"
Output for 5.3.7 - 7.4.0
c3 89 78 c3 89 78
Output for 5.1.4 - 5.3.6
78 c3 89 78
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.1.3
Warning: fopen(php://memory): failed to open stream: Success in /in/984HF on line 7 Warning: fputs(): supplied argument is not a valid stream resource in /in/984HF on line 8 Warning: rewind(): supplied argument is not a valid stream resource in /in/984HF on line 9 Warning: fgetcsv() expects parameter 1 to be resource, boolean given in /in/984HF on line 10 Warning: fclose(): supplied argument is not a valid stream resource in /in/984HF on line 16
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/984HF on line 19
Process exited with code 255.
Output for 4.3.3 - 4.4.9
Warning: fopen(php://memory): failed to open stream: Success in /in/984HF on line 7 Warning: fputs(): supplied argument is not a valid stream resource in /in/984HF on line 8 Warning: rewind(): supplied argument is not a valid stream resource in /in/984HF on line 9 Warning: Wrong parameter count for fgetcsv() in /in/984HF on line 10 Warning: fclose(): supplied argument is not a valid stream resource in /in/984HF on line 16
Output for 4.3.2
Warning: fopen(php://memory): failed to open stream: Inappropriate ioctl for device in /in/984HF on line 7 Warning: fputs(): supplied argument is not a valid stream resource in /in/984HF on line 8 Warning: rewind(): supplied argument is not a valid stream resource in /in/984HF on line 9 Warning: Wrong parameter count for fgetcsv() in /in/984HF on line 10 Warning: fclose(): supplied argument is not a valid stream resource in /in/984HF on line 16
Output for 4.3.0 - 4.3.1
Warning: fopen(php://memory) [http://www.php.net/function.fopen]: failed to create stream: Inappropriate ioctl for device in /in/984HF on line 7 Warning: fputs(): supplied argument is not a valid stream resource in /in/984HF on line 8 Warning: rewind(): supplied argument is not a valid stream resource in /in/984HF on line 9 Warning: Wrong parameter count for fgetcsv() in /in/984HF on line 10 Warning: fclose(): supplied argument is not a valid stream resource in /in/984HF on line 16