How can PHP developers minimize the risk of exposing database credentials when sharing code with clients or third parties?

To minimize the risk of exposing database credentials when sharing code with clients or third parties, PHP developers should store sensitive information like database credentials in a separate configuration file outside of the web root directory. This way, the credentials are not accessible to the public and can be easily excluded from code sharing.

// config.php

define('DB_HOST', 'localhost');
define('DB_USER', 'username');
define('DB_PASS', 'password');
define('DB_NAME', 'database_name');
```

In your PHP code, include the configuration file:

```php
// index.php

require_once('config.php');

// Use the defined constants for database connection
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

// Your database queries go here