No37-ThinkPHP323 study notes

Source: Internet
Author: User
: This article mainly introduces the study notes of No37-ThinkPHP323, for PHP tutorials interested in students can refer. Mentioned above


I recently received an urgent task (a course design) and had to develop a lightweight blog system quickly within a week. so I thought of thinkphp. Although I have learned a PHP before and I have heard of thinkphp for a long time, I have no idea about thinkphp and can download official documents quickly. Start learning!

Thinkphp study notes


1. no space is allowed between the variable type, variable name, and vertex of the variable I method. Otherwise, an error occurs.
2. when the system cannot find the requested operation method, the system locates the empty operation _ empty method for execution, we can optimize error pages and URLs.
3. assume that the access link is http: // localhost/thinkphp/index. php/Home/City/beijing/. if you modify the default operation method suffix:'ACTION_SUFFIX' => 'Action'And then you want to use the _ empty method to output the beijing parameter (in fact, thinkphp initially thought this is the operation method), then, _ empty ( City) City is beijingAction rather than the beijing you want. this is because the beijing is the operation method by default in thinkphp, and the suffix Action is automatically added. At this time, you can get beijing through the built-in ACTION_NAME of thinkphp!
4. if the connection attribute is defined in a model class (both array and DSN can be used), the database connection information will be used when the custom model is instantiated, instead of the default connection information set in the configuration file, it is usually used for some data tables other than the current database connection.
5. it should be noted that the database connection of ThinkPHP is inert, so it is not connected to the database during instantiation, instead, the database is connected only when actual data operations are performed. (in addition, when the system instantiates the model for the first time, will automatically connect to the database to obtain the field information of the data table corresponding to the relevant model class ).
6. the usage of the where method is the essence of ThinkPHP query language and an important component and highlight of ThinkPHP ORM, you can perform common queries, expression queries, quick queries, interval queries, and combined queries. When using string conditions, we recommend that you use the preprocessing mechanism to ensure better security.
7. Generally, you do not need to call the table method. by default, the data table corresponding to or defined in the current model is automatically obtained.
8. the Include tag in thinkphp supports parameter input when the file is included, but note that! Use the [] symbol to pack the variable name (excluding the $ symbol !)
9. if the Field prompt is displayed when inserting data*Doesn' t have a default value. it can be a field name error. Is there a spelling error, or it is a case-insensitive problem (for example, should all be converted to uppercase or lowercase ?)
10. pass the variable array to the template, such$this->assign($data)$ Data is an array ($ data ['Time'], $ data ['user']) with two attributes. You can use {$ time} and {$ user '} to output values in the template. Do not write it as {$ data. time!
11. use jQuery ajax in thinkphp. Note that the parameters are correct. Finally, if you think the code is correct, restart the server and try?

Paste thinkphp official development specifications


1. all class files are. class. php is a suffix (this refers to the class library file used internally by ThinkPHP, which does not represent the class library file loaded externally). It is named by 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 of the Home \ Controller \ UserController class should be Application/Home/Controller/UserController. class. php;
3. make sure that the file name is the same as the call case, because it is case sensitive on Unix-like systems (while ThinkPHP is in the debugging mode, even on Windows platforms, the case sensitivity is strictly checked );
4. the class name and file name are the same (including the case-insensitive). For example, the file name of the UserController class is UserController. class. the file name of the php and InfoModel classes is InfoModel. class. php, and the class names of different class libraries have certain specifications;
5. Functions, configuration files, and other class library files are generally suffixed with. php (third-party introduction is not required );
6. use lowercase letters and underscores to name a function, for example, get_client_ip;
7. the method name uses the camper method, and the first letter is lowercase or the underscore "_", for example, getUserName, _ parseType. Generally, the method starting with an underscore is a private method;
8. the attribute naming method is camper, and the first letter is lowercase or the underscore "_", such as tableName and _ instance. generally, attributes starting with an underscore are private attributes;
9. the function or method with the double underline "_" as the magic method, such as _ call and _ autoload;
10. constants are named with uppercase letters and underscores, such as HAS_ONE and many_to_prop;
11. name the configuration parameter with uppercase letters and underscores (_), for example, HTML_CACHE_ON;
12. language variables are named with uppercase letters and underscores (_). For example, MY_LANG. language variables with the following dashes are usually used for system language variables, such as _ CLASS_NOT_EXIST _;
13. there is no mandatory specification for variable naming, which can be implemented according to team specifications;
14. the template file of thinkphp is suffixed with .html (you can modify it through configuration );
14. data tables and fields are named with lowercase underscores (_ username). Note that the field names must not start with an underscore. for example, the think_user table and the user_name field are correctly written. Data Table fields such as _ username may be filtered out.

Thanks

Thank you for visiting my personal blog. if you feel that this site is helpful to your search and you are satisfied with this site, let's talk about it first, I hope you can share this site with your friends! I would like to express my sincere gratitude to you! :)

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above introduces the study notes of No37-ThinkPHP323, including the content of the aspect, hope to be interested in PHP tutorials to help.

    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.