What is the purpose of hashing passwords in PHP and why is it important for security?

Hashing passwords in PHP is important for security because it helps protect user passwords from being easily compromised in the event of a data breach. When a password is hashed, it is converted into a unique string of characters that cannot be reversed to reveal the original password. This adds an extra layer of security to user accounts and helps prevent unauthorized access.

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