How to include custom PHP file both in header and footer files

You wrote that you have a function definition in file that you include. I suspect that the reason is the function redeclaration error.

You should move the function definition from myCustomFile.php to functions.php.

You can also before each function definition in myCustomFile.php check whether there is already a function of the same name.

if ( ! function_exists('you_function_name') ) {
    function you_function_name() {
        // ...
    }
}