3v4l.org

run code in 300+ PHP versions simultaneously
<?php setlocale(LC_ALL,'C'); $utfchar = chr(0xC3).chr(0x89); // U+009C in UTF-8 $csv = $utfchar."x".$utfchar."x\n"; file_put_contents('test.csv', $csv); $file = fopen('test.csv', 'r'); $data = fgetcsv($file); for ($i = 0; $i < strlen($data[0]); $i++) { echo dechex(ord($data[0][$i])).' '; } echo "\n"; unlink('test.csv'); // expected: c3 89 78 c3 89 78 - "ÉxÉx" // actual: 78 c3 89 78 - "xÉx"
Output for 8.3.0 - 8.3.6
Warning: file_put_contents(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 8 Warning: file_put_contents(test.csv): Failed to open stream: Operation not permitted in /in/Jhpkh on line 8 Warning: fopen(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 9 Warning: fopen(test.csv): Failed to open stream: Operation not permitted in /in/Jhpkh on line 9 Fatal error: Uncaught TypeError: fgetcsv(): Argument #1 ($stream) must be of type resource, false given in /in/Jhpkh:10 Stack trace: #0 /in/Jhpkh(10): fgetcsv(false) #1 {main} thrown in /in/Jhpkh on line 10
Process exited with code 255.
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
Warning: file_put_contents(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 8 Warning: file_put_contents(test.csv): Failed to open stream: Operation not permitted in /in/Jhpkh on line 8 Warning: fopen(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 9 Warning: fopen(test.csv): Failed to open stream: Operation not permitted in /in/Jhpkh on line 9 Fatal error: Uncaught TypeError: fgetcsv(): Argument #1 ($stream) must be of type resource, bool given in /in/Jhpkh:10 Stack trace: #0 /in/Jhpkh(10): fgetcsv(false) #1 {main} thrown in /in/Jhpkh on line 10
Process exited with code 255.
Output for 8.0.13
Warning: file_put_contents(test.csv): Failed to open stream: Read-only file system in /in/Jhpkh on line 8 Warning: fopen(test.csv): Failed to open stream: No such file or directory in /in/Jhpkh on line 9 Fatal error: Uncaught TypeError: fgetcsv(): Argument #1 ($stream) must be of type resource, bool given in /in/Jhpkh:10 Stack trace: #0 /in/Jhpkh(10): fgetcsv(false) #1 {main} thrown in /in/Jhpkh on line 10
Process exited with code 255.
Output for 7.4.33
Warning: file_put_contents(test.csv): failed to open stream: Read-only file system in /in/Jhpkh on line 8 Warning: fopen(test.csv): failed to open stream: No such file or directory in /in/Jhpkh on line 9 Warning: fgetcsv() expects parameter 1 to be resource, bool given in /in/Jhpkh on line 10 Notice: Trying to access array offset on value of type null in /in/Jhpkh on line 12 Warning: unlink(test.csv): Read-only file system in /in/Jhpkh on line 16
Output for 7.4.0 - 7.4.32
Warning: file_put_contents(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 8 Warning: file_put_contents(test.csv): failed to open stream: Operation not permitted in /in/Jhpkh on line 8 Warning: fopen(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 9 Warning: fopen(test.csv): failed to open stream: Operation not permitted in /in/Jhpkh on line 9 Warning: fgetcsv() expects parameter 1 to be resource, bool given in /in/Jhpkh on line 10 Notice: Trying to access array offset on value of type null in /in/Jhpkh on line 12 Warning: unlink(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 16
Output for 7.3.32 - 7.3.33
Warning: file_put_contents(test.csv): failed to open stream: Read-only file system in /in/Jhpkh on line 8 Warning: fopen(test.csv): failed to open stream: No such file or directory in /in/Jhpkh on line 9 Warning: fgetcsv() expects parameter 1 to be resource, bool given in /in/Jhpkh on line 10 Warning: unlink(test.csv): Read-only file system in /in/Jhpkh on line 16
Output for 7.3.0 - 7.3.31
Warning: file_put_contents(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 8 Warning: file_put_contents(test.csv): failed to open stream: Operation not permitted in /in/Jhpkh on line 8 Warning: fopen(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 9 Warning: fopen(test.csv): failed to open stream: Operation not permitted in /in/Jhpkh on line 9 Warning: fgetcsv() expects parameter 1 to be resource, bool given in /in/Jhpkh on line 10 Warning: unlink(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 16
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
Warning: file_put_contents(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 8 Warning: file_put_contents(test.csv): failed to open stream: Operation not permitted in /in/Jhpkh on line 8 Warning: fopen(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 9 Warning: fopen(test.csv): failed to open stream: Operation not permitted in /in/Jhpkh on line 9 Warning: fgetcsv() expects parameter 1 to be resource, boolean given in /in/Jhpkh on line 10 Warning: unlink(): open_basedir restriction in effect. File(test.csv) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Jhpkh on line 16
Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45
Warning: file_put_contents(test.csv): failed to open stream: Permission denied in /in/Jhpkh on line 8 Warning: fopen(test.csv): failed to open stream: No such file or directory in /in/Jhpkh on line 9 Warning: fgetcsv() expects parameter 1 to be resource, boolean given in /in/Jhpkh on line 10 Warning: unlink(test.csv): No such file or directory in /in/Jhpkh on line 16
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.1.6, 5.2.0 - 5.2.2
Warning: file_put_contents(test.csv): failed to open stream: Read-only file system in /in/Jhpkh on line 8 Warning: fopen(test.csv): failed to open stream: No such file or directory in /in/Jhpkh on line 9 Warning: fgetcsv() expects parameter 1 to be resource, boolean given in /in/Jhpkh on line 10 Warning: unlink(test.csv): Read-only file system in /in/Jhpkh on line 16
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/Jhpkh on line 19
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: file_put_contents() in /in/Jhpkh on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: file_put_contents() in /in/Jhpkh on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: file_put_contents() in /in/Jhpkh on line 8

preferences:
284.85 ms | 401 KiB | 459 Q