What are the advantages of using password_hash over MCrypt for password hashing in PHP?

Using password_hash over MCrypt for password hashing in PHP is advantageous because password_hash is a built-in function specifically designed for securely hashing passwords. It automatically generates a random salt and uses a strong hashing algorithm, making it more secure and less prone to vulnerabilities compared to manually implementing hashing with MCrypt.

$password = "password123";
$hashed_password = password_hash($password, PASSWORD_DEFAULT);

// Store $hashed_password in the database