3v4l.org

run code in 300+ PHP versions simultaneously
<?php final readonly class File { /** * @var resource */ private mixed $resource; public function __construct(string $file) { $this->resource = fopen($file, 'r'); } public function close(): void { fclose($this->resource); } public function rewind(): void { rewind($this->resource); } } $f = new File(__FILE__); $f->close(); $f->rewind();
Output for 8.2.11
Fatal error: Uncaught TypeError: rewind(): supplied resource is not a valid stream resource in /in/kljvE:22 Stack trace: #0 /in/kljvE(22): rewind(Resource id #5) #1 /in/kljvE(28): File->rewind() #2 {main} thrown in /in/kljvE on line 22
Process exited with code 255.

preferences:
176.65 ms | 1434 KiB | 20 Q