3v4l.org

run code in 300+ PHP versions simultaneously
<?php $file = __DIR__ . '/IDoNotExist.txt'; var_dump(stat( $file )); var_dump(lstat( $file )); $fp = fopen($file, "r"); $fstat = fstat($fp); fclose($fp); var_dump($fstat); $fileObject = new SplFileObject( $file ); var_dump($fileObject->fstat());
Output for 8.3.0 - 8.3.7
Warning: stat(): stat failed for /in/IDoNotExist.txt in /in/4IEZL on line 5 bool(false) Warning: lstat(): Lstat failed for /in/IDoNotExist.txt in /in/4IEZL on line 6 bool(false) Warning: fopen(/in/IDoNotExist.txt): Failed to open stream: No such file or directory in /in/4IEZL on line 8 Fatal error: Uncaught TypeError: fstat(): Argument #1 ($stream) must be of type resource, false given in /in/4IEZL:9 Stack trace: #0 /in/4IEZL(9): fstat(false) #1 {main} thrown in /in/4IEZL on line 9
Process exited with code 255.
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19
Warning: stat(): stat failed for /in/IDoNotExist.txt in /in/4IEZL on line 5 bool(false) Warning: lstat(): Lstat failed for /in/IDoNotExist.txt in /in/4IEZL on line 6 bool(false) Warning: fopen(/in/IDoNotExist.txt): Failed to open stream: No such file or directory in /in/4IEZL on line 8 Fatal error: Uncaught TypeError: fstat(): Argument #1 ($stream) must be of type resource, bool given in /in/4IEZL:9 Stack trace: #0 /in/4IEZL(9): fstat(false) #1 {main} thrown in /in/4IEZL on line 9
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: stat(): stat failed for /in/IDoNotExist.txt in /in/4IEZL on line 5 bool(false) Warning: lstat(): Lstat failed for /in/IDoNotExist.txt in /in/4IEZL on line 6 bool(false) Warning: fopen(/in/IDoNotExist.txt): failed to open stream: No such file or directory in /in/4IEZL on line 8 Warning: fstat() expects parameter 1 to be resource, bool given in /in/4IEZL on line 9 Warning: fclose() expects parameter 1 to be resource, bool given in /in/4IEZL on line 10 bool(false) Fatal error: Uncaught RuntimeException: SplFileObject::__construct(/in/IDoNotExist.txt): failed to open stream: No such file or directory in /in/4IEZL:13 Stack trace: #0 /in/4IEZL(13): SplFileObject->__construct('/in/IDoNotExist...') #1 {main} thrown in /in/4IEZL on line 13
Process exited with code 255.

preferences:
127.85 ms | 402 KiB | 123 Q