3v4l.org

run code in 500+ PHP versions simultaneously
<?php $paths = [ sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'bishop', tempnam(sys_get_temp_dir(), 'bishop'), ]; foreach ($paths as $path) { $fileW = new \SplFileObject($path, 'w'); $fileW->fputcsv(range(0,2)); assert(6 === $fileW->getSize()); echo $fileW->getSize() . PHP_EOL; $fileR = new \SplFileObject($path, 'r'); assert(6 === $fileR->getSize()); echo $fileR->getSize() . PHP_EOL; }
Output for 8.6.0
Deprecated: Method SplFileObject::fputcsv() is deprecated since 8.6 in /in/vLlb0 on line 9 Deprecated: SplFileObject::fputcsv(): the $escape parameter must be provided, as its default value will change, either explicitly or via SplFileObject::setCsvControl() in /in/vLlb0 on line 9 6 6 Deprecated: Method SplFileObject::fputcsv() is deprecated since 8.6 in /in/vLlb0 on line 9 Deprecated: SplFileObject::fputcsv(): the $escape parameter must be provided, as its default value will change, either explicitly or via SplFileObject::setCsvControl() in /in/vLlb0 on line 9 6 6
Output for 8.4.5 - 8.4.28, 8.5.0 - 8.5.13
Deprecated: SplFileObject::fputcsv(): the $escape parameter must be provided, as its default value will change, either explicitly or via SplFileObject::setCsvControl() in /in/vLlb0 on line 9 6 6 Deprecated: SplFileObject::fputcsv(): the $escape parameter must be provided, as its default value will change, either explicitly or via SplFileObject::setCsvControl() in /in/vLlb0 on line 9 6 6
Output for 8.4.1 - 8.4.4
Deprecated: SplFileObject::fputcsv(): the $escape parameter must be provided, as its default value will change, either explicitly or via SplFileObject::setCsvControl() in /in/vLlb0 on line 9 6 6 Deprecated: SplFileObject::fputcsv(): the $escape parameter must be provided, as its default value will change, either explicitly or via SplFileObject::setCsvControl() in /in/vLlb0 on line 9 Fatal error: Uncaught AssertionError: assert(6 === $fileW->getSize()) in /in/vLlb0:10 Stack trace: #0 /in/vLlb0(10): assert(false, 'assert(6 === $f...') #1 {main} thrown in /in/vLlb0 on line 10
Process exited with code 255.
Output for 8.3.18 - 8.3.37
6 6 6 6
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.36, 8.3.0 - 8.3.17
6 6 Fatal error: Uncaught AssertionError: assert(6 === $fileW->getSize()) in /in/vLlb0:10 Stack trace: #0 /in/vLlb0(10): assert(false, 'assert(6 === $f...') #1 {main} thrown in /in/vLlb0 on line 10
Process exited with code 255.
Output for 7.2.30 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 7.1.29 - 7.1.33, 7.2.0 - 7.2.28, 7.1.17 - 7.1.27, 7.0.0 - 7.0.33, 7.1.0 - 7.1.15
6 6 Warning: assert(): assert(6 === $fileW->getSize()) failed in /in/vLlb0 on line 10 0 Warning: assert(): assert(6 === $fileR->getSize()) failed in /in/vLlb0 on line 14 0
Output for 7.2.29, 7.1.28, 7.1.16
6 Fatal error: Uncaught RuntimeException: SplFileObject::__construct(/tmp/bishop): failed to open stream: No such file or directory in /in/vLlb0:13 Stack trace: #0 /in/vLlb0(13): SplFileObject->__construct('/tmp/bishop', 'r') #1 {main} thrown in /in/vLlb0 on line 13
Process exited with code 255.
Output for 5.6.38 - 5.6.40, 5.5.0 - 5.5.38, 5.6.0 - 5.6.36
6 6 Warning: assert(): Assertion failed in /in/vLlb0 on line 10 0 Warning: assert(): Assertion failed in /in/vLlb0 on line 14 0
Output for 5.6.37
6 6 Warning: assert(): Assertion failed in /in/vLlb0 on line 10 0 Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileObject::__construct(/tmp/bishopWeJzDg): failed to open stream: No such file or directory' in /in/vLlb0:13 Stack trace: #0 /in/vLlb0(13): SplFileObject->__construct('/tmp/bishopWeJz...', 'r') #1 {main} thrown in /in/vLlb0 on line 13
Process exited with code 255.

preferences:
93.86 ms | 1208 KiB | 6 Q