note 61161 deleted from function.tempnam by mazzanet
| From: | mazzanet@php.net | Date: | Fri, 27 Jan 2006 10:14:38 +0000 |
| Subject: | note 61161 deleted from function.tempnam by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-102542@lists.php.net to get a copy of this message | ||
Note Submitter: didikdwi at gmail dot com
----
In addition, if you work with tempnam(),
you can't use fread() to read file contents.
As solution, use file_get_contents().
Example:
<?php
$tmp = tempnam('C:\tmp', 'test');
$fp = fopen($tmp, 'w+');
fwrite($fp, 'test temporary');
fclose($fp);
// This is like in tmpfile(), but
// will not work as desired.
fseek($tmp, 0);
$data = fread($tmp, 1024);
echo $data;
// This is work properly
$data = file_get_contents($tmp);
echo $data;
unlink($tmp);
?>