|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-04-27 13:19 UTC] tonicpeddler at cs dot com
I think some php users might find it useful if you could declare a variable as a static variable. When the script finishes executing, PHP rewrites the original declaration of those variables to the values they had at the end of script execution. Maybe I'm wrong, or maybe there's a more effective way to accomplish this, but there is certainly a very obvious and simple syntax for such a feature. static $var = value; It would certainly simplify a lot for me, and probably at least a few other people. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 14:00:01 2025 UTC |
My suggestion is a feature that could be used for instance, to remember settings without accessing a file or a database to find out what those settings are. For instance, something like this: example.php <?php STATIC VARIABLE $fontcolor = '#0000FF'; echo <<<EOT <html> <body text="$fontcolor"> Hello, this is the colorMy suggestion is a feature that could be used for instance, to remember settings without accessing a file or a database to find out what those settings are. For instance, something like this: example.php <?php STATIC VARIABLE $fontcolor = 'white'; if ( $newcolor != "" ) { $fontcolor = $newcolor; $message = "Congratulations on your new color!"; } echo <<<EOT <html> <body text="$fontcolor"> <p align=center> Hello, this is the color. You may choose a new color like <a href="example.php?newcolor=red">Red</a>. </p> </body> </html> EOT; // end of script ?>