What are the best practices for naming and including external PHP files for database connections?

When naming and including external PHP files for database connections, it is important to choose descriptive and consistent file names to easily identify their purpose. It is also recommended to store sensitive information like database credentials in a separate configuration file that is not publicly accessible. To include external PHP files for database connections, use the require_once or include_once functions to ensure the files are only included once to avoid conflicts.

// config.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myDB";
?>

// db_connection.php
<?php
require_once('config.php');

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>