PHP micro-Credit public development notes (eight)

Source: Internet
Author: User
Tags current time expression key words
PHP micro-Credit Public Development Notes series
Date: 2014.9.6

Today's main to do: the establishment of keyword database, time-out mechanism, optimized keyword matching, expression information database

Note: PHP Echo does not return after? will continue to execute??

2014.9.11 to organize notes:
Write this note, in the rush function, so that is simply a few strokes of the work of the time, now the function developed almost, just to tidy up the previous notes. It was very simple to record the above sentences.

This day is Saturday, not working overtime in the rented house to rest. Because to the mid-Autumn Festival, in Shenzhen, my sister this day will come to my side of the festival, so this day has not much time to write functions. Get up early in the morning to run, and then come back to start tossing (now think about it, you will really become a workaholic). The function of this day is to create a data table of keywords in the database, expression information datasheet, adding timeout mechanism and optimizing keyword matching.

First, the key words data table
This data table stores the information is mainly I do before the keyword filter, capture the use of some keywords. Because you want to be easy to manage, think about putting these in the database, and then write a function to fetch the information, then do a match so that I don't have to write all the information to death in the code and be more flexible. With this idea, we began to organize the data sheet.
There is nothing to mention about the operation of the database, this is mainly to record the operation in the code:
1, the first is to obtain all the keywords:
The simple thing is to get the whole data out of the list of keywords in the database:
SELECT * FROM XXX to select the information for datasheet xxx;

The resulting information is then stored in a two-dimensional array:

vchly/nt0lxeudi8/ltk0mxposhloam8yni+ cjkhorxdtb3by7nyvpy0ysr9vt2x7bxe0mxpotauuvojrl7nysfx9rnyvpy0yrxexqxf5mhlo7o8yni+ cjxwpsrxz8jo0tdo0qq1w7w9xqxf5lw9tctv4tk70ndk/b7d0mxpoqosylu689tz1/bpwtk7sr21xlmk1/ eho9lyzqrv4sdvtcs52lz8tmrkx72r1u7i57xy1rehorxnu7chosdpvnlwrsdgtcs05ttayv2+3b/io6y2+ npdu6e3osvnuf3atlxev8ne3mrhwfi157uwoajywmdpvnkjrmv50ttu2txiwo/ f0lbpsrvkx9aux7dtw7xexme49mlux2fycmf5llb4ysfkudpdtcrzdhjzdhiokbqvyv3atnf2xdc2z7xeo7o8l3a+cjxwpjxpbwcgc3jjpq== " /program/uploadpic/2014-9/201492512823654.png "alt=" >


The specific code, as shown in the above illustration, so I got this keyword in the datasheet of the data row, and then I do the next step according to its type (the data table contains keywords, keyword types of these two fields, there are two information I can do according to the keyword type to do the corresponding operation):



The next operation is the direct use of the previous code, I just cut the structure here. Referred to the optimization of the keyword

Second, facial expression database
The reply message is to be able to reply the expression, here I not use the emoji expression, but the most common kind, such as "Smile" with "/::)" This to show that I built the expression data sheet is to smile as a keyword, "/::)" As the value, and then add an expression type, a total of these three fields. When used, use the direct input smile, then get its value and then reply, you can use. Also only involves the operation of the database, here is not much verbose.

Third, the time-out mechanism
Because the public number uses $_session to store information such as authenticating the user, and the menu type selected. Feel the need to regularly clean up these, for example, the user chose the menu, and then long time no use, then it is best to use the next time when not in the menu, but should be out. With this in mind, I looked up the information on the Web: either to clean up all the $_session on a regular basis or to clear individual $_session on a regular basis. To do regularly, then need to know the time, combined with what I used to do hand-travel items, want to do a regular nothing is to remember the opening time, and then in every use of the time to make judgments on it.

On implementation, I first record the time that a $_session is stored, such as the time to authenticate a user:



The Psa_time () shown above is only a wrapper to the time () function provided by the system. So I get the time to authenticate, and then I get the current time each time the user does it, to compare it to the time of the record:



This will achieve what I call the time-out mechanism.


PHP Learning Record:
After Echo, does the function go on? Before, I reply to the information is not unified control, maybe some modules I will directly reply. But I found that even if I replied to the message with ECHO, I would still execute the code snippet after Echo, which I don't know.

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.