php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40951 combination of header() and imagegif/png/jpeg() makes script run more than once
Submitted: 2007-03-29 17:25 UTC Modified: 2007-04-03 08:25 UTC
From: zirephoenix at rogers dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.4.6 OS: Linux
Private report: No CVE-ID: None
 [2007-03-29 17:25 UTC] zirephoenix at rogers dot com
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-29 17:57 UTC] zirephoenix at rogers dot com
This bug was only for FireFox 1.5.x.  Seems to be gone in 2.
 [2007-04-03 08:25 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 25 13:00:03 2025 UTC