3v4l.org

run code in 300+ PHP versions simultaneously
<?php $file = new \SplTempFileObject(-1); $written = $file->fwrite('readable content'); $file->fflush(); $file->rewind(); var_dump($file->getFileInfo()->getPathname()); var_dump($file->valid()); var_dump($file->isReadable()); var_dump($file->fread($written)); var_dump($file->isWritable()); $written += $file->fwrite(' is writable'); $file->fflush(); $file->rewind(); var_dump($file->fread($written));
Output for 7.1.25 - 7.1.28, 7.2.0 - 7.2.33, 7.3.0 - 7.3.24, 7.4.0 - 7.4.13, 8.0.0
string(12) "php://memory" bool(true) bool(false) string(16) "readable content" bool(false) string(28) "readable content is writable"