thinkphp study 02

Source: Internet
Author: User

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

Related Article

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.