Home  >  Article  >  Backend Development  >  Detailed explanation of ThinkPHP's N method example_PHP tutorial

Detailed explanation of ThinkPHP's N method example_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:24:18712browse

ThinkPHP’s N method is a counter method and is used for core queries, cache statistics and statistics. But it can actually be used for other counting purposes in the application. The usage is relatively simple. The calling format:

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);

means that each time execution reaches this position, the counter will be incremented by 1. Before 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 statistical results after the N method page is executed will not be carried over to the next statistics.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825499.htmlTechArticleThinkPHP’s N method is a counter method and is used for core queries, cache statistics and statistics. But it can actually be used for other counting purposes in the application. The usage is relatively simple. Call...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn