Detailed explanation of ThinkPHP's N method example_PHP tutorial

WBOY
Release: 2016-07-13 10:24:18
Original
766 people have browsed it

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

Copy after login

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

Copy after login

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

Copy after login

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template