Home > PHP Framework > ThinkPHP > How to use n method in thinkphp

How to use n method in thinkphp

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2022-03-07 10:39:35
Original
2348 people have browsed it

In thinkphp, the n method belongs to the counter method, which is used for core queries, cache statistics, and statistics. The syntax is "N('counting position'[,'step value'])"; n The statistical results after the method page is executed will not be carried over to the next statistics.

How to use n method in thinkphp

The operating environment of this article: Windows 10 system, ThinkPHP version 5, Dell G3 computer.

How to use the n method in thinkphp

The 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 is:

N('计数位置'[,'步进值'])
Copy after login

. For example, if we want to count the number of queries on the page, we can use

N('read',1);
Copy after login

to indicate that each execution This position will cause the counter to increase 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.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to use n method in thinkphp. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template