Efficiency for including files of functions (in PHP)

Jos*_*ren 11 php performance include server-side-includes

如果我有大量的函数,最好将它们全部保存在一个大文件中,或者将它们分成几个相关函数的文件会更好.通过更好,我的意思是更高效的可维护性和服务器处理请求.

例如,我现在将所有文件都放在一个名为的文件中include.php.但是如果有一个包含文件包括以下内容会更明智:

<?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');
?>
Run Code Online (Sandbox Code Playgroud)

ech*_*cho 20

出于可维护性的考虑,绝对将它们分开.我怀疑性能会受到影响,但即使它确实存在(只是一点点),你最好还是编写可维护的,可读的代码.

  • +1用于在php中传播可维护性和可读性. (2认同)