Start your MVC with PHP (a) Integrate your site portal

Source: Internet
Author: User
This is a file that describes how to use PHP to implement MVC pattern development. Technical articles about the MVC pattern are available on the Web, so this document will no longer describe the pros and cons of this model (actually I'm not sure), and I'll talk about his PHP technology implementation. And in the later series of articles are mainly speaking technology.

First, the implementation of a unified Web site portal (in MVC call the Controler layer method, that is, the control layer)


You may often see such a path on the Internet (http://www.aaa.com/aaa/bbb/aaa?id=5), it is puzzling that such a site can be implemented in several ways:
1, hidden file extension, the benefits of this approach, there are divergent views, but personally feel that there is no need;
2, the use of the Web site redirection rules to achieve virtual path;
3, the way to enforce file resolution, the implementation of virtual path.
Using the 23rd method can achieve the unified interface of the website, reasonable integration of the site, better reflect the security and structure of the site, in both ways, most of the sites are using "MVC" mode structure

Built and realized.


Here is an example

The access path is as follows:
.../test/*******/bad
.../test/*******/good
(the "Hu" can be replaced with any string, "..." is your Web path)

The directory structure of the file is as follows
|--. htaccess
|--Test
|--application.php
|--controler/goodcontroler.php
|--controler/badcontroler.php

Note that the file ". htaccess", which cannot be built directly under Windows, can be established in command-line mode.


File 0: (. htaccess) (this file is used to change the configuration of Apache)
<files test>
Forcetype application/x-httpd-php
</files>

Document 1: (test.php)

<?php
/*-------------------------------------
* test.php
*
* File as an entry point for your website
* For initialization and entry
* Call to perform controler calls
*
-------------------------------------*/
Require "application.php";
$AA = new Application ();
$aa->parse ();
$aa->go ();

?>

Document 2: (goodcontroler.php)

?

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.