I was curious about the behavior of tmpfile() and whether or not invoking it like
$temp = tmpfile();
Would create a file on disk or in memory. Perhaps it depends on the underlying system? In that case, is there a "more-often-than-not" case where most systems use one or the other?
The documentation implies that it would be created on disk, and specifically says to look for details in your system's implementation of tmpfile(3).
tmpfile(3) (on Linux) says Glibc will try the path prefix P_tmpdir defined in stdio.h, and if that fails the directory /tmp.
If you're looking for an in-memory temp file, perhaps you want php://temp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With