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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: grandadmirale at yahoo dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 04:01:29 2025 UTC