从分离 css、phpfles 和数据库的意义上来说,PHP 编码的标准是什么
给我最好的 PHP 编码标准方法。 在哪里存储我的 css、php、图像等。如何分隔我的文件夹,有多少个文件夹以及该文件夹的名称是什么?
Give me the best standard way of coding in PHP. where to store my css, php, images etc. How to separate my folders, How many folders and whats the name of that folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
没有标准。 PHP 是一种语言,而不是一个框架,与任何语言一样,您可以按照您认为合适的方式组织您的项目。
然而,有一些用 PHP 编写的优秀框架,具有目录结构并提供工具等。例如,Cake PHP和代码点火器。
There is no standard. PHP is a language, not a framework, and as with any language, you can organize your project however you see fit.
However, there are some great frameworks written in PHP that have a directory structure and provide tools, etc. For example, Cake PHP and Code Igniter.
没有最好或标准的方法 - 这正是您可以从项目工作经验中获得的知识 - 在开始编程之前它不是您需要的东西 - 我什至建议将所有内容都保存在同一个文件夹中如果它是一个只有几个文件的小应用程序。 确实,随着时间和经验的积累,你会找到自己的方法的。
There is no best or standard way - that's the exactly kind of knowledge that you can gain from experience of working on projects - it is not something essential that you need before you can start programming - I would even suggest to keep all in the same folder if it's a small app with just couple of files. Really, you'll get your ways with time and experience.
您假设有最好的方法来做到这一点,但实际上没有。 这完全取决于您的应用程序架构和个人喜好。
我可以给您一些通用提示:
You are assuming that there is a best way to do that, and there isn't. It is completely dependent on your application architecture and personal preference.
I can give you a couple of generic hints:
我通常做的就是下一个:
儿子
希望我能帮助你
What I use to do is the next:
and son on
hope I've helped you
我不确定“最佳标准”,因为我认为你会发现它是
很大程度上是主观的,并且取决于其他因素,例如您所使用的任何框架
使用和您的项目的规模。
但是,我倾向于坚持以下约定:-
包含库名称的子文件夹,例如 lib/events/employee/)。
像这样相当逻辑地构建事物需要使用 __autoload()
在加载文件时非常方便。
布局。
我注意到这些天捆绑 js/styles/images 文件夹的约定
进入他们自己的“公共”(rails)或“静态”(django)文件夹,这些文件夹也可能是
更好。
I'm not sure about the "best standard" because I think you'll find it is
largely subjective and dependent on other factors e.g. any frameworks you're
using and the size of your project.
However, I've tended to stick with the following convention:-
sub folders containing the libraries name e.g. lib/events/employee/).
Structuring things fairly logically like this makes the use of __autoload()
quite handy when it comes to loading your files in.
layout.
I've noticed the conventions these days to bundle the js/styles/images folder
into their own 'public' (rails) or 'static' (django) folders which might also be
nicer.