What are the potential security risks of storing login credentials in PHP code?

Storing login credentials in PHP code poses a security risk because if the code is exposed or accessed by unauthorized individuals, they can easily obtain the sensitive information. To mitigate this risk, it is recommended to store login credentials in a separate configuration file outside of the web root directory.

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

Then, in your PHP code, include the configuration file:

```php
// index.php
<?php
include 'config.php';

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