What are potential pitfalls when trying to include external scripts in PHP code?

One potential pitfall when including external scripts in PHP code is the risk of exposing sensitive information, such as database credentials, if the external script is not properly secured. To avoid this, it is important to store sensitive information in a separate configuration file outside of the web root directory and include it in your PHP script using a relative path.

<?php
// config.php
return [
    'db_host' => 'localhost',
    'db_user' => 'username',
    'db_pass' => 'password',
    'db_name' => 'database'
];

// index.php
$config = include 'config.php';

$connection = new mysqli($config['db_host'], $config['db_user'], $config['db_pass'], $config['db_name']);