Start the journey: using the ThinkPHP framework

Source: Internet
Author: User
ThinkPHP is interesting. to use this framework, you must create an entry file. According to the official documentation, ThinkPHP must and can only contain one entry file

Start the journey: using the ThinkPHP framework

1. create the ThinkPHP entry file:

ThinkPHP is interesting. to use this framework, you must create an entry file. According to the official documentation, ThinkPHP must and can only contain one entry file. That is to say, all server connections use this file for turnaround. In other words, every access through a browser must be done through "http: // server address/entry file location/application module name/specific operation name/GET variable parameter.

Comparison with Struts:

For example, to access the next Action named Index on the Myapp2 site

Struts (server port 8080): http: // 127.0.0.1: 8080/Myapp2/index. do

ThinkPHP (server port 80): http: // 127.0.0.1/Myapp2/index. php/Index/index/

The interesting thing is that index. php is the first file to be created. All services must use this file for turnover. Next we will use the index in blue. What is this. It is very interesting to say that this is the name of a method in the IndexAction file in ThinkPHP. that is to say, ThinkPHP is easy to use and can define many methods in the Action, then, access the service by writing the Action name + method name in the address. It is more convenient.

However, this operation method may seem awkward, and the action attribute of the form may be quite awkward (normally it should be action = "Index/index ", but here it will be changed to action = "index. php/Index/index ")

Fortunately, the index. php part may be removed through the subsequent configuration, that is, the/index. php/section can be omitted in the address bar. In this way, the access address will change to a previously familiar form.

Okay, that's all. Let's talk about how to create this index. php entry file.

The procedure is simple. create a php file named index. php under the root directory of your project.

Copy the following code and save it.

// Load the framework entry file

Require ("./ThinkPHP. php ");

// Instantiate a website application instance

App: run ();

Then press F11 to execute the command, and the following screen will be OK.

Then go back to EPP3 and refresh the directory. Many directories and several files are automatically created.

In this case, ThinkPHP is used normally.

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.