From: full_ot at directbox dot com
Operating system: Win2k
PHP version: 4.3.6
PHP Bug Type: Class/Object related
Bug description: unset class-variable combinated with echo causes script to run twice
Description:
------------
System: Win2k SP4, Apache 2.0.49 PHP 4.3.6
(also tested on Win2k SP4, Apache 2.0.48 PHP 4.3.4 with same result)
I have a class that handle news in a CMS. So it also have to save the news
in single files.
The srcipt below is the essence of that class. But it seems to run twice,
because the save-function creates two files with different timestamps.
Regardless it is only called once.
If u use the first line of show() all is working fine, but the second line
with the img-tag causes trouble.
The variable $image_url ist know to the class but its uninitialized.
Nevertheless this shouldnt cause such unexpected behaviour.
Reproduce code:
---------------
class news{
var $image_url, $timestamp;
function show(){
// echo $this->image_url; echo $this->image_url; //working fine
(returns nothing, create one file)
echo "<img src=\"".$this->image_url."\"
alt=\"".$this->image_url."\">"; //this causes the script to run twice
}
function save(){
$fp = fopen($this->timestamp, "w");
fclose($fp);
}
}
$news = new news;
$news->timestamp = microtime();
$news->save();
$news->show();
Expected result:
----------------
It should save one! file to disk and print nothing on the screen (cause
$image_url is empty). The name of the file is the timestamp of its
creation.
--
Edit bug report at http://bugs.php.net/?id=28630&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28630&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28630&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28630&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28630&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28630&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28630&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28630&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28630&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28630&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28630&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28630&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28630&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28630&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28630&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28630&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28630&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28630&r=float