What are the best practices for migrating code from PHP 5.4 to PHP 7.2?

When migrating code from PHP 5.4 to PHP 7.2, it is important to address deprecated features, syntax changes, and potential compatibility issues. This may involve updating functions, classes, and libraries to ensure compatibility with the newer PHP version.

// PHP 5.4 code
mysql_connect('localhost', 'username', 'password');

// PHP 7.2 code
$mysqli = new mysqli('localhost', 'username', 'password');
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}