ThinkPHP's N method example _ PHP-php Tutorial

Source: Internet
Author: User
The N method of ThinkPHP is a counter method. This article mainly introduces the N method of ThinkPHP. For more information, see ThinkPHP.

The N method of ThinkPHP is a counter method used for core queries and cache statistics. But it can be used for other counting purposes of the application. the usage is relatively simple. The Call format is as follows:

N ('Count position' [, 'step value'])

For example, to count the number of queries on the page, you can use

N ('read', 1 );

This indicates that each execution at this position will cause the counter to add 1. before the page ends, we can use

$ Count = N ('read ');

To count the number of queries executed on the current page.
If you want to increase the counter by 5 each time, you can change the step value, for example:

N ('score ', 5 );

Note that the statistical results after the N method page is executed are not included in the next statistics.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.