What are the differences between using mysqli as an object and mysql as a resource in PHP7, and how can these impact code functionality?

When using mysqli as an object in PHP7, you have access to object-oriented methods for interacting with a MySQL database, making it more secure and easier to use. On the other hand, using mysql as a resource is deprecated and should be avoided as it poses security risks and may lead to compatibility issues in future PHP versions.

// Using mysqli as an object
$mysqli = new mysqli("localhost", "username", "password", "database");
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

// Using mysql as a resource (deprecated)
$mysql = mysql_connect("localhost", "username", "password");
if (!$mysql) {
    die("Connection failed: " . mysql_error());
}