note 106624 deleted from function.tmpfile by danbrown
| From: | danbrown@php.net | Date: | Wed, 30 Nov 2011 21:07:23 +0000 |
| Subject: | note 106624 deleted from function.tmpfile by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184830@lists.php.net to get a copy of this message | ||
Note Submitter: kexianbin at diyism dot com
----
A clean method to use tempory file:
<?
$tmp_meta=stream_get_meta_data(tmpfile());
file_put_contents($tmp_meta['uri'], 'hello');
echo file_get_contents($tmp_meta['uri']);
?>
without need to fclose the tmp file, it will be deleted while the php ends.