PHP WeChat public development notes (5) _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP public development notes (5 ). PHP public development notes (5) PHP public development Notes Series date: 2014.9.3 today I have completed the authentication function and then improved the search function. In fact, the main thing is to take notes on behalf of the PHP public development (V)
PHP public development Notes Series date: 2014.9.3
Today, I completed the authentication function and improved the search function. In fact, the main thing is to organize the entire code structure. it can be said that it is a modular design.
Modular design of our public account.Because our previously mentioned functional requirements include: 1. menu-query function. Considering the extended functions in the future, I want to implement these modules: menu module (in this way, we need to add new menu functions in the future, which can be operated directly in this module, in this way, modification and maintenance are also simple, and there will be no conflicts between developers when there may be division of labor and collaboration in the future); 2. the database module (here it is mainly responsible for database-related work, such as adding, modifying, and querying); these are two functional requirements. Later, I thought about it. the public account is not only used for queries, so I have the following ideas: 3. what do I need to interact with in some cases, therefore, I use the "menu" command as the menu module entry, that is, the "menu" is sent to the menu module of the service number, and then the "query" command is sent, the specific query function is displayed. The menu module is exited when "exit" is sent. 4. after we exit the menu module, a module called keyword capture will be used to respond to user operations and capture specific user commands to interact with users.
5. some operations, such as parsing the address information in the database, keyword reply tips and other general functions, should be encapsulated into an operation module.
Based on the above considerations and ideas, the directory structure of our public code now includes: PHP code, no error prompt (unknown), so many syntax errors can only be uploaded to SAEs, I can check it only by sending a message (of course, this also means that I am very careless). it is often: either the function name is wrong or the function parameter name is wrong, either the statement ends with a semicolon or the variable is preceded by a $ symbol... A lot of such errors; 2. Database: During account information authentication, I forgot to connect to the database first because the authentication was performed before I searched for the function. Then, when I perform authentication, because I want to find information in the database, but I am not connected to the database, I keep searching for errors... After a long time, this also exposes my inattentive problem; 3. abuse of require/include/require_once/include_once. In PHP, it seems that the include and require files cannot be repeated, so there are require_once and include_once files. At that time, my understanding of the non-repeated inclusion was that the same file could not be contained repeatedly (the function was always included multiple times). later I realized that this was not the meaning. My current solution is to use the functions in tools. I only use the index. include in php, and then use require_once to operate functions in the module, because I may call functions between modules. If include is used, it is not guaranteed that the inclusion relationship can be handled properly.

Remark (5) PHP public development Notes Series date: 2014.9.3 today, I completed the authentication function and then improved the search function. In fact, the main thing is to replace the entire generation...

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.