fwrite in PHP4
| From: | Otakar Nejezchleb | Date: | Tue, 27 Feb 2001 10:16:11 +0000 |
| Subject: | fwrite in PHP4 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-41824@lists.php.net to get a copy of this message | ||
This script works properly under PHP 3.0.18, but in PHP 4.0.4pl1 is the
result file empty. When I add commented line #2 instead of calling MyEcho,
it works correctly. When I add lines #1, it works somehow strange. After
fwrite and fclose is file empty and after second fopen (and no fwrite) "OK"
appears in it. What am I doing wrong?
<?
function MyEcho($Text)
{
global $GlPOutputFile, $GlOutputFile;
fwrite($GlPOutputFile, $Text);
#1 fclose($GlPOutputFile);
#1 copy($GlOutputFile, "after_write");
#1 $GlPOutputFile=fopen($GlOutputFile, 'a');
}
{
$GlOutputFile=uniqid("/tmp/").".tmp";
$GlPOutputFile=fopen($GlOutputFile, "w");
MyEcho("OK");
#2 fwrite($GlPOutputFile, "OK");
fclose($GlPOutputFile);
copy($GlOutputFile, "result");
unlink($GlOutputFile);
}
?>