PHP WeChat Public Development Notes (5)
PHP WeChat public development notes series
Date: 2014.9.3
Today I implemented the identity verification function and then improved the search function. In fact, the main thing is to organize the entire code structure, which can be said to be a modular design.
Modular design of our official account.
Because among the functional requirements we mentioned earlier:
1. Menu--Query function. Considering the expansion of functions in the later stage, I want to implement these sub-modules: Menu module (in this way, if we need to add new menu functions in the future, we can operate them directly in this module, so that correction and maintenance are simple. Considering the later stage, There may be no conflicts between developers when they work together);
2. Database module (here mainly responsible for database-related work, such as adding, modifying, querying, etc.); this is for the two functional requirements proposed at that time.
Later, I thought about it, and the official account is not only used for query work, so I came up with the following ideas:
3. Sometimes you may need to interact or something, so I use the "menu" command as the entrance to the menu module we implemented. That is, sending "menu" will enter the menu module of the service account, and then send the "query" command. , and enter the specific query function. Sending "Exit" exits the menu module.
4. After we exit the menu module, the instructions sent by the user will have a module called keyword capture to respond to the user's operations and capture specific user instructions to interact with the user.
5. There are some operations, such as parsing address information in the database, some keyword reply tips and other general functions, we should be able to encapsulate them into an operation module.
Based on the above considerations and ideas, our public account code directory structure now has:
PHP code, there is no error message (I don’t know), so many syntax errors can only be checked by sending messages after uploading to SAE (of course this also shows that I am sloppy), often: or function name If it is written incorrectly, either the function parameter name is written incorrectly, or the statement is missing a semicolon at the end, or the $ symbol is missing in front of the variable. . . There are many such mistakes;
2. Database: When doing account information authentication, because this authentication was before my search function, I forgot to connect to the database first. Then when I was doing authentication, I was looking for information in the database, but I was not connected to the database, so I kept looking for errors. . . After struggling for a long time, this also exposed my lack of carefulness;
3. Abuse of require/include/require_once/include_once. It seems that include and require files cannot be repeated in PHP, so there are require_once and include_once. At that time, my understanding of the non-repeated inclusion was that the same file could not be re-included (there was always an error that the function was included multiple times), but later I realized that this was not what it meant. My current approach is to include functions in tools only in index.php, and then use require_once for functions in modules.
To operate, because I may call functions between modules. If include is used, there is no guarantee that this inclusion relationship can be handled well.
http://www.bkjia.com/PHPjc/879189.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/879189.htmlTechArticlePHP WeChat Public Development Notes (5) PHP WeChat Public Development Notes Series Date: 2014.9.3 I did the identity verification today function, and then improved the search function. In fact, the main thing is to convert the entire code...