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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC