ThinkPHP中的MVC开发模式了解一
ThinkPHP中的MVC开发模式理解一
MVC这三个字母不愧博大精深,当我自以为要马上攻破php最后一道难关的时候,那时候的我好想就想错了,当我研究了一个半月之后,竟然发现其思想是那么的难以理解,直到现在我也不得不承认我只是对这个思想的认识只是一个皮毛,对于很底层的东西还是不太理解,还有别的要说的,但先说一下我对MVC的理解:
其实MVC并不是一个什么语法或者算法,只是一个开发模式,说道开发模式,我所知道的有传统的MODEL模式,即过程化的处理,而MVC则是对结构做了一个很好的优化,更像是一种开发规范,你必须要根据规范去执行,才能够去使用其内部的各种库,就像小孩子只有听大人的话大人才能给买吃的,说到这,肯呢过还是不太明白,那就具体的说一下MVC,MVC你一眼就应该可以看出来这是字母的缩写即分别为M:模型V: 视图 C:控制器。
这养的话,我们就应该知道,MVC至少有这三个最为基础的东西,模型,先简单的说一下比如数据模型,像你的数据库配置哪些什么的,当然这里的模型还会有分支,一开始学的时候不建议再往下多想,到明白的时候自然会明白,那么V呢,这是MVC最容易理解的地方了,就是视图,说白了就是用户看到的前端页面,这个没有说明难以理解的,可以过去,下面就是最为重要的控制器了,这个起到了中枢神经的作用,你既然能看到这里,就一定知道APACHE的作用是什么了,是一样的道理,起到了分配,逻辑处理,程序结构等等很多重要的功能,我之前卡死就卡死到控制器上面了,因为即便你去按照规范去创建了控制器可是你还是对于之后的种种规范感觉难以理解,在自己的内心里,就永远没有那种明白的感觉,总感觉是朦朦胧胧的,其实就是不明白,这个过程是无法传授的,自能依靠自己去理解,自由自己真正的理解了,问题才会有好的解决。
其实额外的理解,因为我们或许知道作为一般的程序开发,我们都是尽量做到业务的分离,只有业务之间完全分离,才能支持大型的团体的项目开发,所以说,都是这样,jquery的诞生原因之一就是我们有对html代码结构和行为的分离,这样增强了代码的可维护性,你可能会拿html5反驳我,至于html5的诞生,我可感到很费解,除了在移动端对用户的体验提高之外,没有发现太大的亮点,但有一个在我看来致命的弱点,就是之前我们仅仅对于前段页面而言是结构,样式,行为,分别由html,css,和JavaScript提供支持,但是,html5的一些新的属性明显越界了,这样不就是明显的与代码分离原则相违背把,这可能需要另一种思考方式,但是从我个人的方面来看是不太好的。那么在回到MVC,其一个重要的原则就是做到了业务分离,大的方面,前端设计和后台业务逻辑的分离,小的方面,数据设计和逻辑处理的分离等等,这样,对于大型的团队开发,对于后期维护是非常高效的,这也是MVC在各种开发语言大受欢迎的原因之一。
我现在学的thinkphp,就是一种MVC框架,相对于其他的框架简单一些,但还是不太好理解,我的总结是,想要学好这些东西,还是要多写代码,多分析过程和错误原因,这是非常重要的,最好还要写一下文档,以前我绝得写文档很没有必要,单后后来发现,文档可以让子自己很明确开发思路,因为开发后台就怕脑子浑,一旦发浑,就不知所以然了,所以写文档是很不错的。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.
