PHP Password Functions

About This Index
This page is the PHP Password Functions index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
Learn how to store and check passwords safely on /php/password. Use this page when you need a specific helper such as password_hash(), password_verify(), or password_needs_rehash().
Start with password_hash() and password_verify()—then learn password_needs_rehash() to keep old hashes strong.
How to Call a Password Function
Password helpers are global functions—hash when a user signs up, verify when they log in:
$hash = password_hash($password, PASSWORD_DEFAULT);
if (password_verify($typed, $hash)) {
if (password_needs_rehash($hash, PASSWORD_DEFAULT)) {
$hash = password_hash($typed, PASSWORD_DEFAULT);
}
echo 'Welcome back';
}
$info = password_get_info($hash);
$algos = password_algos(); PHP Password Functions Table
All function guides in this PHP tutorial series (5 tutorials in 3 categories).
Hash & verify
2 functionsCreate a safe hash when a user signs up, and check it when they log in.
| Function | Description | Tutorial |
|---|---|---|
password_hash() | Create a secure, salted hash of a password for storage. | Try it |
password_verify() | Check whether a password matches a hash from password_hash(). | Try it |
Inspect & upgrade
2 functionsRead a hash and find out when it should be rehashed with newer settings.
| Function | Description | Tutorial |
|---|---|---|
password_get_info() | Return the algorithm, algorithm name, and options of a password hash. | Try it |
password_needs_rehash() | Check whether a hash uses outdated settings and should be rehashed. | Try it |
Algorithms
1 functionSee which hashing algorithms your PHP supports (PHP 7.4+).
| Function | Description | Tutorial |
|---|---|---|
password_algos() | List the password hashing algorithm IDs available in this PHP build (PHP 7.4+). | Try it |
Frequently Asked Questions
Start with password_algos()
Open the first guide—syntax, examples, and FAQs.
CODETOFUN NEWS
Stay Ahead in Tech
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful
