How can one check if a connection to a database is successfully established in PHP?

To check if a connection to a database is successfully established in PHP, you can use the `mysqli_connect()` function to connect to the database and then check if the connection was successful by evaluating the return value.

// Establish connection to the database
$connection = mysqli_connect("localhost", "username", "password", "database_name");

// Check if the connection was successful
if (!$connection) {
    die("Connection failed: " . mysqli_connect_error());
} else {
    echo "Connected successfully";
}