PHP只需要文件中的特定功能

时间:2017-08-15 16:16:14

标签: php require function-calls

我可以要求/ include / import在另一个.php文件中声明的特定函数,而不需要/ include / import整个文件,就像在Java中一样吗?例如:

文件1

function test(){echo "OK";}

function test2(){echo "Not OK";}

file2的

require "file1.php test"
test();

1 个答案:

答案 0 :(得分:1)

首先,即使使用Java,整个文件都包含在内,你只是看不到幕后发生的事情。

简单回答,将您的功能添加到自己的文件中,也称为OOP。

相关问题