php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26514 Static variables double
Submitted: 2003-12-03 14:53 UTC Modified: 2003-12-04 06:54 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: grandadmirale at yahoo dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.3.4 OS: WinXP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 - 13 = ?
Subscribe to this entry?

 
 [2003-12-03 14:53 UTC] grandadmirale at yahoo dot com
Description:
------------
When using static variables and the .= operand, the static variable doubles itself.

Reproduce code:
---------------
function test()
{
   static $test = '';
   $test .= 'lala|';
   echo $test;
}

test();
test();
test();

Expected result:
----------------
lala|lala|lala|

Actual result:
--------------
lala|lala|lala|lala|lala|lala|

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-04 02:08 UTC] sniper@php.net
This is exactly what 'static' does..

RTFM:
http://www.php.net/manual/en/language.variables.scope.php

 [2003-12-04 06:54 UTC] sniper@php.net
Hint: Try change the echo line to:

echo $test, "\n";


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 19:01:30 2024 UTC