If a file is included or required inside a function is it loaded if the function is not invoked? Example:
page.php
<?php
require('functions.php');
a();
?>
functions.php
<?php
function a(){
require('a.php');
}
function b(){
require('b.php');
}
function c(){
include('c.php');
}
?>
Are b.php or c.php loaded?
No they aren’t loaded unless you actually call the functions
b()andc().The code inside
b.phpandc.phpwill also be local to the functions they are included in. That is any variables they define won’t be available outside ofb()orc()respectively.See PHP: include for more details.