PHP instance Development (3) The thinkphp of MVC Learning in PHP

Source: Internet
Author: User

the thinkphp of MVC Learning in PHP1. What is MVC

MVC exists in the desktop program, m refers to the data model, v refers to the user interface, C is the controller. The purpose of using MVC is to separate the implementation code for M and V

MVC is a design pattern that makes it mandatory to separate the input, processing, and output of an application. Using an MVC application is divided into three core parts: model, view, controller. Each of them handles their own tasks.

2. Why to use MVC

First, the most important point is that multiple views can share a model, and now more and more ways to access your application. Since the data returned by the model is not formatted, the same artifacts can be used by different interfaces.

Once again, the development cycle shortens, facilitates maintenance and management to reduce development costs and workload.

Any thing can have its drawbacks, let's take a look:

The drawback of MVC is that it doesn't have a clear definition, so it's not easy to fully understand MVC. Using MVC requires careful planning, and because its internal principles are complex, it takes some time to think.

MVC is not a good fit for small or medium-sized applications, and spending a lot of time applying MVC to applications that are not large in size will often outweigh the costs.

3. Recognize an MVC framework thinkphp

Thinkphp is a fast, simple object-oriented, lightweight PHP development framework that follows the Apache2 Open source protocol and is permanently free to use, and is created to simplify enterprise application development and Agile Web application development. With thinkphp, you can develop and deploy Web apps more easily and quickly

Characteristics

Easy-to-use MVC pattern

Original core compilation and project compilation mechanism

Built-in XML template engine, support tag Library

Rich model support

The directory structure is automatically created

Distributed database Support

Multi-database connection and switchover support

Curd and operating highly automated support

Attention:

thinkphp3.2php Version Requirements
    • PHP5.3 above version ( Note: Php5.3dev version and PHP6 are not supported)

See http://document.thinkphp.cn/manual_3_2.html for details

4, how to build a thinkphp

Download the ThinkPHP3.1 version framework package and directly refer to the thinkphp.php file in the directory to

The file index.php code is as follows:

<? PHP Define ("Think_path", "thinkphp/"); Define ("App_name", ' 43_mvc_thinkphp '); Define ("App_path", '. ') ); require_once (Think_path. " thinkphp.php "); $app New App ();? >

The controller code is as follows:

<?PHP//This class is automatically generated by the system and is intended for testing purposes onlyHeader("Content-type:text/html;charset=utf-8");classIndexactionextendsAction { Public functionindex () {$this->show (' <style type= "text/css" >*{padding:0; margin:0;} div{padding:4px 48px;} body{background: #fff; font- Family: "Microsoft Jas Black"; Color: #333;} h1{font-size:100px; font-weight:normal; margin-bottom:12px;} p{line-height:1.8em; font-size:36px}&LT;/STYLE&GT;&L T;div style= "padding:24px 48px;" > ); }     Public functionShow () {Echo"New Method <br>"; }}

PHP instance Development (3) The thinkphp of MVC Learning in PHP

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.