I have a large function that I wish to load only when it is needed. So I assume using include is the way to go. But I need several support functions as well -only used in go
I have a large function that I wish to load only when it is needed. So I assume using include is the way to go.
Your base assumption is wrong. This kind of optimization is counter-productive; even if your function is hundreds of lines long there will be no noticeable benefit to hiding it from PHP's parser. The cost for PHP to parse a file is negligible; real noticeable speed gains come from finding better algorithms or from better ways to talk to your database.
That said, you should be including the function definition in the included file. Rather than moving the body of the function into func_1.php, move the entire function into the file. You can then require_once the file containing the function inside each file where you need it, and be sure that it is included exactly once regardless of how many times you attempt to include it.
An example:
function test() {
}
require_once('file1.php');
include('table_of_contents.php');
test();