note 63820 added to language.variables.scope

From: Date: Fri, 31 Mar 2006 21:02:37 +0000
Subject: note 63820 added to language.variables.scope
Groups: php.notes 
Request: Send a blank email to php-notes+get-107102@lists.php.net to get a copy of this message
<?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. ?> ---- Server IP: 195.136.184.34 Probable Submitter: 83.30.213.218 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/language.variables.scope.php Edit -- http://master.php.net/note/edit/63820 Del: integrated -- http://master.php.net/note/delete/63820/integrated Del: useless -- http://master.php.net/note/delete/63820/useless Del: bad code -- http://master.php.net/note/delete/63820/bad+code Del: spam -- http://master.php.net/note/delete/63820/spam Del: non-english -- http://master.php.net/note/delete/63820/non-english Del: in docs -- http://master.php.net/note/delete/63820/in+docs Del: other reasons-- http://master.php.net/note/delete/63820 Reject -- http://master.php.net/note/reject/63820 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#107102) next »