3v4l.org

run code in 300+ PHP versions simultaneously
<?php $spl = new SplFileObject('php://temp', 'r'); $fh = fopen('php://temp', 'r'); var_export([ 'SplFileObject::fputcsv result on failure' => $spl->fputcsv(['foo', 'bar']), 'SplFileObject::fwrite result on failure' => $spl->fwrite('foo'), 'fputcsv result on failure' => fputcsv($fh, ['foo', 'bar']), 'fwrite result on failure' => fwrite($fh, 'foo'), ]);
Output for 7.4.4 - 7.4.30, 8.0.0 - 8.0.20, 8.1.0 - 8.1.7
array ( 'SplFileObject::fputcsv result on failure' => false, 'SplFileObject::fwrite result on failure' => false, 'fputcsv result on failure' => false, 'fwrite result on failure' => false, )
Output for 7.4.0
array ( 'SplFileObject::fputcsv result on failure' => -1, 'SplFileObject::fwrite result on failure' => false, 'fputcsv result on failure' => false, 'fwrite result on failure' => false, )
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
array ( 'SplFileObject::fputcsv result on failure' => 0, 'SplFileObject::fwrite result on failure' => 0, 'fputcsv result on failure' => 0, 'fwrite result on failure' => 0, )

preferences:
69.78 ms | 412 KiB | 5 Q