Are there built-in PHP functions that can handle encoding special characters in passwords for authentication purposes?

When handling passwords for authentication purposes, it is crucial to properly encode special characters to prevent security vulnerabilities such as SQL injection attacks. PHP provides built-in functions like `password_hash()` and `password_verify()` that handle password hashing and verification securely, including encoding special characters. By using these functions, you can ensure that passwords are properly encoded and stored securely in your application.

$password = "P@ssw0rd";
$hashed_password = password_hash($password, PASSWORD_DEFAULT);

// Store $hashed_password in your database

// Verify the password
$entered_password = "P@ssw0rd";
if (password_verify($entered_password, $hashed_password)) {
    echo "Password is correct!";
} else {
    echo "Password is incorrect!";
}