PHP微信公众开发笔记(五)
PHP微信公众开发笔记(五)
PHP微信公众开发笔记系列 日期:2014.9.3今天做了身份验证的功能,然后完善了下搜索功能。其实主要的是将整个代码结构整理了一番,应该可以说是模块化设计吧。
模块化设计我们的公众号。 因为我们之前提的功能需求中有: 1、菜单--查询功能。我考虑到后期功能的扩展,就想将这些分模块来实现:菜单模块(这样,今后我们需要添加新的菜单功能,可以直接在这个模块里操作,这样修正和维护也简单,在考虑到后期可能会分工协作的时候各开发者之间不会产生冲突); 2、数据库模块(这里就主要是负责数据库相关的工作,如添加、修改、查询等);这是针对当时提出的两个功能需求。 后来我想了想,公众号不仅仅是用来做查询工作的,因此我又有了以下的构想: 3、有的时候可能需要互动啥的,因此我就将“菜单”指令作为我们实现的菜单模块的入口,即发送“菜单”就会进入服务号的菜单模块中,然后再发送“查询”指令,就进入了具体的查询功能了。而发送“退出”则退出了菜单模块。 4、在我们退出了菜单模块后,用户发送的指令将会有一个叫做关键词捕获的模块来响应用户的操作,捕获特定的用户指令来跟用户做互动。
5、有一些操作,如解析数据库中地址信息、一些关键词回复tips等通用功能,我们应该又可以封装为一个操作模块了。
基于以上考虑和构想,现在我们的公众号代码目录结构有: PHP代码,没有错误提示(不知道),所以好多语法错误都只能在上传到SAE后,我通过发送消息才检查得到(当然这也说明我很马虎),经常是:要么函数名写错了,要么是函数参数名写错了,要么是语句少些了分号结尾,要么是变量前面少写了$符号。。。好多这样的错误; 2、数据库:做帐号信息认证的时候,因为这个认证在我搜索功能之前,所以就忘了首先连接到数据库。然后我在做认证的时候,因为要查找数据库中的信息,但是我没有连接到数据库,所以就一直查找错误查找错误。。。折腾了好久,这也暴露出了我不够细心的毛病; 3、require/include/require_once/include_once 这些滥用。PHP中好像是不能重复include、require文件,所以就有require_once 、include_once 这两个了。当时我对那个不能重复包含的理解是同一个文件中不能重复包含(就老是出现函数多次被包含的错误),后来才知道不是这个意思。我现在的处理方法是,tools里面的函数,我只在index.php里头include,然后模块内的函数用require_once 来操作,因为我可能模块间会互相调用函数,如果用include的话,不保证能处理好这个包含关系。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to delete Xiaohongshu notes? Notes can be edited in the Xiaohongshu APP. Most users don’t know how to delete Xiaohongshu notes. Next, the editor brings users pictures and texts on how to delete Xiaohongshu notes. Tutorial, interested users come and take a look! Xiaohongshu usage tutorial How to delete Xiaohongshu notes 1. First open the Xiaohongshu APP and enter the main page, select [Me] in the lower right corner to enter the special area; 2. Then in the My area, click on the note page shown in the picture below , select the note you want to delete; 3. Enter the note page, click [three dots] in the upper right corner; 4. Finally, the function bar will expand at the bottom, click [Delete] to complete.

Notes deleted from Xiaohongshu cannot be recovered. As a knowledge sharing and shopping platform, Xiaohongshu provides users with the function of recording notes and collecting useful information. According to Xiaohongshu’s official statement, deleted notes cannot be recovered. The Xiaohongshu platform does not provide a dedicated note recovery function. This means that once a note is deleted in Xiaohongshu, whether it is accidentally deleted or for other reasons, it is generally impossible to retrieve the deleted content from the platform. If you encounter special circumstances, you can try to contact Xiaohongshu’s customer service team to see if they can help solve the problem.

As a Xiaohongshu user, we have all encountered the situation where published notes suddenly disappeared, which is undoubtedly confusing and worrying. In this case, what should we do? This article will focus on the topic of "What to do if the notes published by Xiaohongshu are missing" and give you a detailed answer. 1. What should I do if the notes published by Xiaohongshu are missing? First, don't panic. If you find that your notes are missing, staying calm is key and don't panic. This may be caused by platform system failure or operational errors. Checking release records is easy. Just open the Xiaohongshu App and click "Me" → "Publish" → "All Publications" to view your own publishing records. Here you can easily find previously published notes. 3.Repost. If found

Link AppleNotes on iPhone using the Add Link feature. Notes: You can only create links between Apple Notes on iPhone if you have iOS17 installed. Open the Notes app on your iPhone. Now, open the note where you want to add the link. You can also choose to create a new note. Click anywhere on the screen. This will show you a menu. Click the arrow on the right to see the "Add link" option. click it. Now you can type the name of the note or the web page URL. Then, click Done in the upper right corner and the added link will appear in the note. If you want to add a link to a word, just double-click the word to select it, select "Add Link" and press

How to add product links in notes in Xiaohongshu? In the Xiaohongshu app, users can not only browse various contents but also shop, so there is a lot of content about shopping recommendations and good product sharing in this app. If If you are an expert on this app, you can also share some shopping experiences, find merchants for cooperation, add links in notes, etc. Many people are willing to use this app for shopping, because it is not only convenient, but also has many Experts will make some recommendations. You can browse interesting content and see if there are any clothing products that suit you. Let’s take a look at how to add product links to notes! How to add product links to Xiaohongshu Notes Open the app on the desktop of your mobile phone. Click on the app homepage

As a lifestyle sharing platform, Xiaohongshu covers notes in various fields such as food, travel, and beauty. Many users want to share their notes on Xiaohongshu but don’t know how to do it. In this article, we will detail the process of posting notes on Xiaohongshu and explore how to block specific users on the platform. 1. How to publish notes tutorial on Xiaohongshu? 1. Register and log in: First, you need to download the Xiaohongshu APP on your mobile phone and complete the registration and login. It is very important to complete your personal information in the personal center. By uploading your avatar, filling in your nickname and personal introduction, you can make it easier for other users to understand your information, and also help them pay better attention to your notes. 3. Select the publishing channel: At the bottom of the homepage, click the "Send Notes" button and select the channel you want to publish.

In 2022, Apple added a new feature to the Notes app on iPhone and iPad that allows you to quickly scan printed or handwritten text and save it in a digital text format. Read on to learn how it works. On earlier versions of iOS and iPadOS, scanning text into Apple's Notes app required tapping the note's text field and then tapping the "Live Text" option in the pop-up menu. However, Apple is making it easier to digitize real-world notes in 2022. The following steps show you how to do this on a device running iOS 15.4 or iPadOS 15.4 and above. On your iPhone or iPad, open "

Most people write down everything, including recipes, birthdays, song lyrics, and more. on their iPhone’s Notes app. But many iPhone users reported that they deleted very important notes on their iPhone by mistake and now they are very nervous and frustrated. They don't know how to restore it on iPhone. We have done a lot of research on the matter and found two methods to recover deleted notes from iPhone. In this article, we will explain these two methods with which you can easily get back deleted notes. How to Recover Deleted Notes via Notes App Step 1: You should first launch the Notes app from the home screen on your iPhone. Step 2: Launch the Notes application
