Original: thinkphp study 02
first, what is MVC
M-model writing Model classes to manipulate data
V-view Writing HTML files, page rendering
C-controller Writing class files (UserAction.class.php)
Second, the MVC characteristics of thinkphp
third, the thinkphp of the MVC corresponding directory
M project directory/application directory/lib/model
V project directory/application directory/TPL
C project directory/application directory/lib/action
iv. URL Access c
v. 4 ways to access URLs
1.PATHINFO Mode--KEY!!!!!!
HTTP//project name/Portal File/Module name/method name/Key 1/value 1/Key 2/value 2
such as: Http://localhost/thinkphp/test/index.php/Index/show
Under PathInfo mode, URLs are customizable, for example, by modifying the configuration under config.php:
<?phpreturn Array (//' configuration item ' = ' config value ' = ' url_pathinfo_depr ' = '-',//change PATHINFO parameter delimiter. The default is///' url_case_insensitive ' =>true, //Open case-insensitive);? >
2. Normal mode
HTTP//Name/project/portal file? m= Module name &a= method name & key 1= value 1& key 2= value 2
such as: Http://localhost/thinkphp/test/index.php?m=Index&a=show
3.REWRITE mode
HTTP//project name/Module name/method name/Key 1/value 1/Key 2/value 2
(1) Need Apache support, open httpd.conf
Turn on the rewrite function and restart Apache
1 # LoadModule rewrite_module modules/mod_rewrite.so //Remove # #
View Code
(2) Place the. htaccess under the project folder
1 <ifmodule mod_rewrite.c>2 rewriteengineon3 Rewritecond%{ Request_filename}-D4 rewritecond%{request_filename}-F5 Rewriterule ^ (. *) $ index.php/$1 [qsa,pt,L]6 </IfModule>
OK, then you can http://localhost/thinkphp/test/Index/show direct access without adding index.php
4. Compatibility mode
HTTP//Name/project name/entry file? S= Module Name/method name/Key 1/value 1/Key 2/value 2
such as: Http://localhost/thinkphp/test/Index.php/?s=Index/show
You may encounter a cache problem at the beginning of the adjustment by deleting the runtime folder or turning on debug mode
Turn on debug mode, default is off
Define (' App_debug ', true);
Note that when you turn on debug mode, you should pay attention to the case specification on the URL, otherwise you will get an error, or you can set the config.php
' Url_case_insensitive ' =>true, //turn on case insensitive
thinkphp study 02