#26514 [Bgs]: Static variables double
| From: | sniper@php.net | Date: | Thu, 04 Dec 2003 11:54:09 +0000 |
| Subject: | #26514 [Bgs]: Static variables double | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-51680@lists.php.net to get a copy of this message | ||
ID: 26514
Updated by: sniper@php.net
Reported By: grandadmirale at yahoo dot com
Status: Bogus
Bug Type: Variables related
Operating System: WinXP
PHP Version: 4.3.4
New Comment:
Hint: Try change the echo line to:
echo $test, "\n";
Previous Comments:
------------------------------------------------------------------------
[2003-12-04 02:08:44] sniper@php.net
This is exactly what 'static' does..
RTFM:
http://www.php.net/manual/en/language.variables.scope.php
------------------------------------------------------------------------
[2003-12-03 14:53:21] 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|
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26514&edit=1