English 中文(简体)
为什么我应该在php网站中使用MVC?[已关闭]
原标题:Why should I use MVC in a php website? [closed]
  • 时间:2010-10-14 18:30:21
  •  标签:
  • php
Closed. This question is opinion-based. It is not currently accepting answers.

想改进这个问题吗 更新问题,以便通过编辑此文章用事实和引文回答问题。

Closed 8 years ago.

Many frameworks are based on mvc, but I have no idea about MVC. So what is the use of MVC? Is it for speed, security or any other reason?

最佳回答

MVC允许您将业务逻辑与表示层分离。这种“关注点分离”允许您快速查找和编辑代码的部分。它还可以在整个系统中方便地重用UI组件。

查看wiki页面,了解MVC的过度学术和技术介绍http://en.wikipedia.org/wiki/Model_view_controller

问题回答

MVC主要是为了提高代码的可维护性。通过将数据库逻辑与表示逻辑与控制器逻辑分离,您可以更容易地进行更改/重写/维护。

it also solves the problem of "spaghetti code", you can outsorce your HTML/XML/PDF/XSL creation Code to your View/Template engine, get the Data from Your Model(DB/File/RemoteCall,...) and your Controller controls the behaviour of Both, you can also simply exchange the View/Models without even Change the Controller if u implement it right, so you gain Seperation of Concerncs, get better Code & Maintainability and can easily swap components also its easier to manage if your projects grow. I recommend the Usage of a FrontController which selects the right Controller for you depending on the Users input, you can also use Inversion of Control/DependencyInjection Pattern there and let your Controller be configued by your FrontController / Pass DB Connection and lots of lots of lots more funny stuff Now u got a simple application framwork:) Use Zend Instead:)





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签