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
 [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: Fri Mar 01 00:01:28 2024 UTC