Are there specific best practices for securely storing database credentials in PHP scripts?

Storing database credentials securely in PHP scripts is crucial to prevent unauthorized access to sensitive information. One best practice is to store credentials in a separate configuration file outside of the web root directory and restrict access to it. Encrypting the credentials or using environment variables are also recommended methods to enhance security.

// config.php
define('DB_HOST', 'localhost');
define('DB_USER', 'username');
define('DB_PASS', 'password');
define('DB_NAME', 'database_name');
```

To access the credentials in your PHP script:
```php
include 'config.php';

$connection = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

if ($connection->connect_error) {
    die("Connection failed: " . $connection->connect_error);
}