What are some best practices for updating outdated PHP code to meet current standards and requirements?

Issue: Updating outdated PHP code to meet current standards and requirements involves identifying deprecated functions, replacing them with modern equivalents, improving security measures, and optimizing performance. Code snippet:

// Before updating:
mysql_connect('localhost', 'username', 'password');
mysql_select_db('database_name');

// After updating:
$mysqli = new mysqli('localhost', 'username', 'password', 'database_name');
if ($mysqli->connect_error) {
    die('Connection failed: ' . $mysqli->connect_error);
}