note 63820 deleted from language.variables.scope by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 May 2009 01:36:26 +0000 |
| Subject: | note 63820 deleted from language.variables.scope by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155562@lists.php.net to get a copy of this message | ||
Note Submitter: SasQ
----
<?php
I use PHP 4.3 and it's impossible to assign a variable or function result to a static variable
:-( Example:
function SomeFunction()
{
$LocalVar = 5;
static $MyStaticVar1 = some_function(); //ERROR
static $MyStaticVar2 = $LocalVar //ERROR
static $MyStaticVar3 = 7; //OK
return $MyStaticVar3++;
}
It's a little annoying, because in some cases the value of static variables aren't
necessarily known at the moment of their initialisation. And sometimes it's required to be a
value returned by some function or a value of some other function created earlier. Unfortunately,
the moment of the initialization is the only moment, when this kind of assignment is possible to
execute only on the first time the function is called.
?>