3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* * The value of the $escape parameter doesn't matter * unless it's set to the one character that makes sense * then it f's up the escaping and produces invalid CSV data * */ $fh = fopen('php://stdout', 'w'); fputcsv($fh, ['using default', 'a,"b'], ',', '"'); fputcsv($fh, ['using " ', 'a,"b'], ',', '"', '"'); fputcsv($fh, ['using x ', 'a,"b'], ',', '"', 'x'); fputcsv($fh, ['using \\ ', 'a,"b'], ',', '"', '\\');
based on GHk1F
Output for 5.5.4 - 5.6.31, hhvm-3.11.1 - 3.22.0, 7.0.0 - 7.1.10
"using default","a,""b" "using " ","a,"b" "using x ","a,""b" "using \ ","a,""b"
Output for 5.4.0 - 5.5.3, hhvm-3.10.1
"using default","a,""b" Warning: fputcsv() expects at most 4 parameters, 5 given in /in/LKkfW on line 11 Warning: fputcsv() expects at most 4 parameters, 5 given in /in/LKkfW on line 12 Warning: fputcsv() expects at most 4 parameters, 5 given in /in/LKkfW on line 13
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/LKkfW on line 10
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 '[' in /in/LKkfW on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/LKkfW on line 10
Process exited with code 255.