Home >Database >Mysql Tutorial >Detailed analysis of the role of static variables in MySQL
This article mainly introduces relevant information that explains the role of static variables in mysql. I hope that through this article, everyone can understand and master the usage of MySQL static variables. Friends in need can refer to the following
Detailed explanation The role of static variables in mysql
Use static variables static variable
Sample code:
##
function Test() { $a = 0; echo $a; $a++; }This function is useless because every time it is called, the value of $a is set to 0 and "0" is output. $a++ that adds one to the variable has no effect, because once you exit this function, the variable $a no longer exists
Sample code:
function Test(){ static $a = 0; echo $a; $a++; }Every time the Test() function is called, the value of $a will be output and incremented by 1; static variables also provide a way to deal with recursive functions. A recursive function is a function that calls itself.
The above is the detailed content of Detailed analysis of the role of static variables in MySQL. For more information, please follow other related articles on the PHP Chinese website!