3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fgetcsv_dump($csv) { $url = 'data://text/plain,' . urlencode($csv); $handle = fopen($url, 'r'); echo '"', addcslashes($csv, "\0..\37!@\177..\377"), "\"\n"; var_dump(fgetcsv($handle)); echo "\n"; } fgetcsv_dump("foo\",bar\n"); fgetcsv_dump("\",bar"); fgetcsv_dump("\",bar\n"); fgetcsv_dump("");
Output for 8.4.1 - 8.4.13
"foo",bar\n" Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/j52kQ on line 7 array(2) { [0]=> string(4) "foo"" [1]=> string(3) "bar" } "",bar" Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/j52kQ on line 7 array(1) { [0]=> string(4) ",bar" } "",bar\n" Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/j52kQ on line 7 array(1) { [0]=> string(5) ",bar " } "" Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/j52kQ on line 7 bool(false)
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.4, 8.3.6 - 8.3.26
"foo",bar\n" array(2) { [0]=> string(4) "foo"" [1]=> string(3) "bar" } "",bar" array(1) { [0]=> string(4) ",bar" } "",bar\n" array(1) { [0]=> string(5) ",bar " } "" bool(false)
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 "foo",bar\n" array(2) { [0]=> string(4) "foo"" [1]=> string(3) "bar" } "",bar" array(1) { [0]=> string(4) ",bar" } "",bar\n" array(1) { [0]=> string(5) ",bar " } "" bool(false)
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
"foo",bar\n" array(2) { [0]=> string(4) "foo"" [1]=> string(3) "bar" } "",bar" bool(false) "",bar\n" array(1) { [0]=> string(5) ",bar " } "" bool(false)

preferences:
150.93 ms | 412 KiB | 5 Q