Is there a best practice for defining constants in PHP scripts to avoid errors?

Defining constants in PHP scripts can help avoid errors by providing a way to store values that should not be changed throughout the script's execution. To define constants in PHP, you can use the `define()` function to set a constant with a specific name and value. It is a best practice to define constants at the beginning of the script to make them easily accessible and to ensure they are set before being used.

// Define constants
define('DB_HOST', 'localhost');
define('DB_USER', 'username');
define('DB_PASS', 'password');
define('DB_NAME', 'database_name');

// Example usage
$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);