I recently started learning thinkphp. I’m not very good at it. I don’t understand many of the questions, so I want to post them on the homepage. I hope people who see it can answer my questions, so that everyone can interact and learn faster. , I have no other intention. As the saying goes, live until you are old and learn until you are old. I hope you won’t laugh at it.
My approach is very simple. I start with the manual. The manual is the result of the hard work of the author who developed thinkphp, but there are some parts that I don’t understand. If you are lucky enough to encounter similar problems, I hope you can reply.
1.Framework directory
In Chapter 1.6 Directory Structure, the content is as follows:
The directory structure of the new version has been adjusted based on the original to make it clearer.
Directory/File Description
ThinkPHP.php Framework entry file
Common Framework public file directory
Conf Framework configuration file directory
Lang Framework system language directory
Lib System core base class library directory
Tpl System Template Directory
Extend Framework extension directory (for details about the extension directory, please refer to the extension chapter later)
Note: If you download the core version, the Extend directory may be empty, because ThinkPHP itself does not rely on any extensions.
If we open the ThinkPHP directory under the home directory, the main content is as mentioned above, and the screenshot is as shown in Figure 1:
Picture 1
It can be found that the system core base class library is no longer called Lib. This is Library. The Extend directory is mentioned at the beginning, and it is said to be a framework extension directory. It also specifically reminds that this directory is empty in the core version, but I This Extend directory is not found in both ThinkPHP3.2.2 core version and ThinkPHP3.2.2 full version. The screenshot is as follows:
Figure 2. Full version directory
Figure 3. Core version directory
If we open the entire directory, we will see the following content, if 4
Figure 4. Complete table of contents
Here we can see other file directories. Fortunately, the author has placed a README.md file in other directories except the framework directory ThinkPHP to tell us what this directory does,
1.Application: Project Directory
2.Public: resource file directory, which should contain css, js and pictures
3.ThinkPHP: Framework directory, this is where the core classes are placed
4..htaccess: A distributed configuration file. I find this file very complicated when I first come across it. I won’t go into details about the function of this file here
5.index.phh: Entry file
6.README.md: This readme file
2. Naming rules
1. The class name ends with .class.php and is named using camel case. This is very rare for me. It may be because the author has been writing Java for a while before writing this framework, and got some things in Java here. , so I am very curious, because I have been writing .net for a long time. Haha, I hate the way of naming words by dividing them with underscores. I feel that people have to read an array separated by underscores. It is not troublesome. Just read a few. Words are simpler than reading an array, but this underline naming method is a habit of the inventor of PHP, and we have no choice but to accept it.
2. Case, I remember that custom variables in php are case-sensitive, and others are not. But in order to avoid us switching between upper and lower case words, it is recommended to distinguish them. I think it can be used in lower case as much as possible. , when you were doing English reading comprehension in school, did you find it annoying that capitalized words appeared?
3. Keep the class name and file name consistent. This is also a thumbs up, so you can know the class name when you see the file name. This is also stipulated by .net.
4. Functions are named using lowercase letters and underlines, such as: get_client_ip. Why are there no camel case or pascal naming methods? Isn’t this more consistent with reading habits?
5. Constants, language parameters, and configuration parameters are all in capital letters and underlined, which is also unaccustomed and difficult to read.
http://www.bkjia.com/PHPjc/813066.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/813066.htmlTechArticleI recently started learning thinkphp. I’m not very good at it. I don’t understand many of the questions, so I want to share them. Please forgive me for posting them boldly. On the homepage, I hope people who see it can answer my questions so that everyone can interact with each other...