The N method of ThinkPHP belongs to the counter method. This article mainly introduces the N method of ThinkPHP. Friends who need it can refer to it
The N method of ThinkPHP belongs to the counter method and is used for core query and cache. Statistics of counts and statistics. But it can actually be used for other counting purposes in the application. The usage is relatively simple. The calling format is:
N('Counting position'[,'Step value'])
For example, if we want to count the number of queries on the page, we can use
N('read',1);
to indicate that each execution to this position will cause the counter to increase by 1 until the end of the page. , we can use
$count = N('read');
to count the number of queries executed on the current page.
If you want the counter to increase by 5 each time, you can change the step value, for example:
N('score',5);
It should be noted that the N method page has been executed. The latest statistical results will not be carried over to the next statistics.
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
##
The above is the detailed content of Analysis of ThinkPHP's N method. For more information, please follow other related articles on the PHP Chinese website!