Are there any specific PHP functions or methods that can help in dynamically including different config.php files based on the script being executed?

To dynamically include different config.php files based on the script being executed, you can use the `$_SERVER['SCRIPT_FILENAME']` variable to get the current script file path and then construct the path to the appropriate config file. By using this method, you can have different config files for different scripts without hardcoding the file paths.

$scriptPath = $_SERVER['SCRIPT_FILENAME'];
$scriptDir = dirname($scriptPath);
$configFile = $scriptDir . '/config.php';

if (file_exists($configFile)) {
    include $configFile;
} else {
    // Handle error or fallback to a default config file
}