Home > Article > Backend Development > Simplify the parsing of pagination code in PHP template pages_PHP tutorial
When using templates, you will encounter such a problem: it is troublesome to display paging information, and multiple templates have paging blocks.
For example:
---20 records in total, current 3/5 pages Home Page Previous Page Next Page Last Page GO-----
Friends who have encountered this problem for the first time are considering When solving this problem, it seems that everyone is thinking about how to use PHP to implement it, but no matter how you design it, there are two options: 1. Use nested loops to implement it
2. It uses n multiple judgments to do
but it is still troublesome in the end, and server-side resources are used during parsing.
Why not use javascript instead of php! ! ! ! , this can reduce the amount of code in the php script, and can also leave the work of parsing paging to the client itself. However, debugging JavaScript may be more troublesome.
The most important thing is that it can simplify the pain of parsing templates when displaying pagination.
The following is a template parsed by an itx template tool that supports pear.
Where and represent a block, {recordcount} Such similar strings are variables.
----------------list.tpl--------------------------
|