Explain the role of static variables in mysql in detail
- 2021-09-12 02:32:51
- OfStack
Explain the role of static variables in mysql in detail
Use static variables static variable
Sample code:
function Test()
{
$a = 0;
echo $a;
$a++;
}
This function is useless because it sets the value of $a to 0 and outputs "0" every time it is called. Adding 1 to the variable $a + + has no effect, because once 1 exits this function, the variable $a does not exist
Sample code:
function Test(){
static $a = 0;
echo $a;
$a++;
}
Every time the Test () function is called, the value of $a is output and 1 is added; Static variables also provide a way to deal with recursive functions. A recursive function is a function that calls itself.
If you have any questions, please leave a message or go to the community to exchange and discuss, and make progress together. Thank you for reading. I hope I can help you. Thank you for your support to this site!