What potential issues arise when using password_hash for user authentication in PHP?

One potential issue that arises when using password_hash for user authentication in PHP is the need to securely store the generated hash. To solve this issue, it is recommended to use a secure method of storing the hash, such as using a database with proper encryption or hashing techniques.

// Example of securely storing the hash in a database using PDO
$pdo = new PDO('mysql:host=localhost;dbname=database', 'username', 'password');
$username = 'user123';
$password = 'password123';

$hashedPassword = password_hash($password, PASSWORD_DEFAULT);

$stmt = $pdo->prepare("INSERT INTO users (username, password) VALUES (:username, :password)");
$stmt->bindParam(':username', $username);
$stmt->bindParam(':password', $hashedPassword);
$stmt->execute();