no37-thinkphp323 Study Notes

Source: Internet
Author: User
Say in front


Recently received an urgent task (a course design), in a week to make a light blog system, must be developed quickly, so I think of thinkphp. Although I have learned a PHP before, I have heard of thinkphp, but thinkphp is ignorant, rushed to download official documents. Start learning!

thinkphp Study Notes


1. Get variable i method variable type, variable name and point cannot have space between, otherwise error
2. Empty operation refers to the system can not find the requested operation method, will be positioned to the empty operation _empty method to execute, using this mechanism, we could implement the error page and some URL optimization.
3. Assume that the access link is http://localhost/thinkphp/index.php/Home/City/beijing/If you modify the default action method suffix:'ACTION_SUFFIX' => 'Action', and then you want to use the _empty method to output Beijing This parameter (in fact thinkphp initially thought it was an action method), then _empty ( City) Square Method received Take of the City is beijingaction and not the Beijing you want, because thinkphp default Beijing is the action method, and the suffix action is added automatically. At this point, you can get beijing! through the thinkphp built-in Action_name
4. If the connection attribute is defined within a model class (both arrays and DSNs are available), the custom model is instantiated with the defined database connection information instead of the default connection information set in the configuration file. Typically used in some data tables other than the current database connection.
5. It is important to note that the thinkphp database connection is inert, so it is not connected to the database at the time of instantiation, but is connected to the database when there is actual data operation (the extra case is that when the system first instantiates the model, The database is automatically connected to get field information for the corresponding data table for the model class.
6. The use of the Where method is the essence of thinkphp query Language, is also an important part of thinkphp ORM and highlights, can be completed including ordinary query, expression query, quick query, interval query, combined query, including query operations. When using string conditions, it is recommended that you cooperate with the preprocessing mechanism to ensure greater security.
7. In general, you do not need to call the table method, the default is to automatically get the current model corresponding or defined data table.
8. The include tag in thinkphp supports passing in parameters while containing files, but be careful! Use the [] symbol to wrap the variable name when using the variable (not including the $ symbol!). )
9. When inserting data, prompt field*Doesn ' t has a default value, which can be a problem with the field name, misspelled, or case-sensitive (for example, all in uppercase or lowercase) to try? )
10. Pass an array of variables to the template, such as$this->assign($data)Over here$Data is an array ($data[' time ',$data[' user '), with two properties. Then, in the template, you can directly use the {$Time}, {$User '} to output the value. Be careful not to write {$Data.time} Oh!
11. Use jquery Ajax in thinkphp and note the parameters are correct. Finally, if you think the code is true, restart the server to try?

Put it on again. thinkphp Official Development Code


1. class files are suffixed with. class.php (this refers to a class library file that is used internally by thinkphp, does not represent an externally loaded class library file), is named with the Hump method, and capitalized, such as DbMysql.class.php;
2. The namespace address of the class is the same as the path address, for example, the path where the Home\controller\usercontroller class should be application/home/controller/ UserController.class.php;
3. Ensure that file naming and invocation are case-sensitive, because the case sensitivity is on top of Unix-like systems (while thinkphp is strictly checked for capitalization under debug mode, even on Windows platforms);
4. The class name and file name are the same (including the above capitalization), for example, the file name of the Usercontroller class is UserController.class.php, the Infomodel class name is InfoModel.class.php, and the class name of different class library has certain specification;
5. Other class library files, such as functions, configuration files, are usually suffixed with. PHP (third party not required);
6. The naming of functions using lowercase letters and underscores, such as GET_CLIENT_IP;
7. The method is named using the Hump method, and the first letter lowercase or using the underscore "_", for example, Getusername,_parsetype, the method usually preceded by an underscore belongs to the private method;
8. The name of the property uses the Hump method, and the first letter lowercase or use the underscore "_", such as TableName, _instance, usually the underscore attribute is a private property;
9. A function or method preceded by a double underline "__" as a magical method, such as __call and __autoload;
10. Constants are named with uppercase letters and underscores, such as Has_one and Many_to_many;
11. Configuration parameters are named with uppercase letters and underscores, such as html_cache_on;
12. Language variables are named in uppercase letters and underscores, such as My_lang, where a language variable that starts with an underscore is usually used for system language variables, such as _class_not_exist_;
13. The name of the variable is not mandatory specification, can be carried out according to the team norms;
The template file for thinkphp. html is the default suffix (can be modified by configuration).
14. Data tables and fields are named in lowercase and underlined, and note that field names do not start with an underscore, such as the Think_user table and the User_name field are correct, and data table fields like _username may be filtered.

Thank

Thank you for visiting my personal blog friends, if you feel this site on your search for the problem has helped, and feel satisfied with the site, the top of it, I hope you share this site to your friends! I would like to express our heartfelt thanks to you here! :)

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the NO37-THINKPHP323 study notes, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.