Created
January 30, 2017 13:19
-
-
Save shtrih/7c15621747f08f220543e55199c5b2e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getTmp() { | |
// returns file handle, similar to the one returned by fopen, for the new file or false on failure. | |
$handle = tmpfile(); | |
$path = stream_get_meta_data($handle)['uri']; | |
var_dump(fwrite($handle, 'foo')); // 3 | |
var_dump(fread($handle, 42)); // "" | |
var_dump(fgets($handle)); // false | |
var_dump(file_get_contents($path)); // "foo" | |
var_dump(file_exists($path)); // true | |
return $path; | |
} | |
$path = getTmp(); | |
var_dump(file_exists($path)); // false ??? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment