网站结构和php脚本 [英] Site structure and php scripts

查看:48
本文介绍了网站结构和php脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用CMS,它将有大量的用户输入,并且我开始考虑要使用的所有单独的PHP脚本。那是正常的吗?我可以将所有这些文件缩小为一个类吗?

I am working on a CMS currently and it's going to have a fair amount of user input and I am starting to think about all the separate PHP scripts I am going to have. Is that normal? Can I shrink all these files down into one class?

我想这就是我要问的问题。

I guess here's what I am trying to ask.


  1. 是否可以通过整个PHP类从表单或AJAX请求中调用操作或函数,而不是一个小脚本?

  2. 我的资产/脚本(PHP和JavaScript)开始积累。这是正常的吗?

这是我第一次尝试CMS,所以这里总有newbcake。

This is my first CMS attempt so total newbcake here.

推荐答案

在编程中基本上有一种整体式和模块化的方法。

There is basically a monolithic and a modular approach in programming.

整体式,因为您需要的一切都在一个块中(整体)代码。严格来说,由于我们严重依赖于库或其他代码片段,因此今天编写单片代码的机会不多。

Monolithic as in everything you need is in one block (monolith) of code. Strictly speaking we don't have many chances left to write monolithic code today as we depend heavily on libraries or other pieces of code.

模块化意味着将所有内容分成小块易于维护和调试。在这方面,PHP中的所有功能已经是模块。函数和类是模块化方法中的主要对象。

Modular means to split everything in little pieces which are easy to maintain and debug. All the functions in PHP are already modules in that regard. Functions and classes are the main objects in a modular approach.

如果您希望在自己的项目中继续使用此方法,则最终还将对象分解为单个文件,大多是上课的。通过类,我们可以使用自动加载器,甚至不必担心关于包括文件了。

If you like to stay with this approach in your own projects you will eventually also split your objects into single files, mostly with classes. With classes we can us the autoloader and don't even have to worry about including the files anymore.

这篇关于网站结构和php脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆