I'm new to php and have used VisualBasic. Is there a Static type variable in php to hold its value (like a totalizer). I want to just count without having to use a db to hold a value. If you want to respond directly to me. thedog@webbdawg.com
Thanks.
Static Variables
Moderator: General Moderators
static has a slightly different meaning in this context, although Static == Unchanging points to the right direction

and php offers the sameMSDN VB library wrote:In addition to scope, variables have a lifetime
[...]
The next time the procedure is executed, all its local variables are reinitialized.
However, you can preserve the value of a local variable by making the variable static. Use the Static keyword to declare one or more variables inside a procedure, exactly as you would with the Dim statement:
Static Depth
For example, the following function calculates a running total by adding a new value to the total of previous values stored in the static variable Accumulate:
Function RunningTotal(num)
Static ApplesSold
ApplesSold = ApplesSold + num
RunningTotal = ApplesSold
End Function
http://www.php.net/manual/en/language.variables.scope.php#AEN4516 wrote:<?php
function Test()
{
static $a = 0;
echo $a;
$a++;
}