#40951 [NEW]: combination of header() and imagegif/png/jpeg() makes script run more than once

From: Date: Thu, 29 Mar 2007 17:25:50 +0000
Subject: #40951 [NEW]: combination of header() and imagegif/png/jpeg() makes script run more than once
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-110938@lists.php.net to get a copy of this message
From: zirephoenix at rogers dot com Operating system: Linux PHP version: 4.4.6 PHP Bug Type: Scripting Engine problem Bug description: combination of header() and imagegif/png/jpeg() makes script run more than once Description: ------------ Without the header() and imagegif() functions, the code is basically a hit counter script. However, with the combination of those two lines of code, the hit counter will increment by 2. Something is causing the script to run twice. Reproduce code: --------------- <?php $site="test.txt"; $imageFile="image/metro.gif"; $hits=0; if (file_exists($site)) { $temp=file($site); $hits=$temp[0]; } $hits++; $fileHandle=fopen($site, "w"); fputs($fileHandle, $hits); fclose($fileHandle); header("Content-type: image/gif"); imagegif(imagecreatefromgif($imageFile)); ?> Expected result: ---------------- test.txt should increment by 1 every time the script is accessed Actual result: -------------- test.txt increments by 2 every time the script is accessed -- Edit bug report at http://bugs.php.net/?id=40951&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40951&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40951&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40951&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40951&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40951&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40951&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40951&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40951&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40951&r=support Expected behavior: http://bugs.php.net/fix.php?id=40951&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40951&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40951&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40951&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40951&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40951&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40951&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40951&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40951&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40951&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40951&r=mysqlcfg

« previous php.bugs (#110938) next »