How does the password_hash() function handle the storage of the algorithm used for hashing passwords?

When using the password_hash() function in PHP to hash passwords, the algorithm used for hashing is automatically included in the resulting hash. This ensures that the algorithm information is stored along with the hashed password, making it easy to verify the password later using the correct algorithm. This approach simplifies the process of verifying passwords and ensures that the correct algorithm is always used.

$password = "secretPassword";
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);

// Store $hashedPassword in the database