Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the forward and backward functions of history records based on two-way circular queue in php

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you the "php based on two-way circular queue how to achieve historical records forward and backward and other functions", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "php based on two-way circular queue how to achieve historical records forward and backward and other functions" this article.

The details are as follows:

In order to achieve a function of recording the history of operations

1. A function similar to undo and anti-undo. (realize the forward and backward of the operation)

two。 View posts after logging in with discuz forums (you can go forward and backward to view posts, and posts to view history)

3. The logic is the same as the forward and backward function of the windows Explorer address bar.

According to this need, a data structure is implemented. Wrote a general class, temporarily called the history class.

The principle is similar to that of a clock. When you instantiate an object, you can construct a ring with a length of N (which can be fixed as needed)]

And then integrate various operations. Forward, backward, insert, modify insert.

Class can construct an array. Or pass in array parameters to construct an object. You can get the array after each operation. The data after operation can be saved in an appropriate way according to their own needs. You can put it in cookie,session, serialize it, convert it to json, save it in a database, or put it in a file. It is convenient to use next time.

In order to facilitate expansion, store more data. Each piece of data is also an array record.

For example, expand it as needed: array ('path'= >' DRV _ peg _ www _ value)

By the way, post a file for debugging variables written by yourself.

1. Pr () can format and highlight the output variable. Pr ($arr), pr ($arr,1) is exited after output.

2. Debug_out () is used to output multiple variables. The default is to quit.

3. Debug_out ($_ GET,$_SERVER,$_POST,$arr)

History.class.php file:

Debug.php file:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report