Efficiency for including files of functions (in PHP)(包含函数文件的效率(在 PHP 中))
问题描述
如果我有大量函数,最好将它们全部保存在一个大文件中,或者将它们分成几个相关函数的文件.更好是指在可维护性和处理请求的服务器方面更高效.
If I had a large number of functions would it be better to keep them all in one large file or would it be better to separate them into several files of related functions. By better I mean more efficient for both maintainability and for the server processing the request.
例如,现在我将所有文件都放在一个名为 include.php
的文件中.但是拥有一个包含如下内容的包含文件会更明智:
For example right now I have all my files in a file named include.php
. But would it be wiser to have an include file of includes like:
<?php
include('/functions/user.php');
include('/functions/admin.php');
include('/functions/content.php');
include('/functions/nav.php');
include('/functions/database.php');
include('/functions/other_junk.php');
?>
推荐答案
为了可维护性,一定要把它们分开.我怀疑性能是否会受到影响,但即使它会受到影响(只是一点点),你最好还是编写可维护、可读的代码.
Definitely separate them, for maintainability sake. I doubt performance will suffer at all, but even if it does (just a teensy bit) you're better off writing maintainable, readable code.
这篇关于包含函数文件的效率(在 PHP 中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:包含函数文件的效率(在 PHP 中)


基础教程推荐
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01