Content · Web Development · PHP

PHP password_algos() Function: Usage and Examples

password_algos returns the password-hashing algorithms currently supported by the runtime, including registered algorithm.

1 views Published Oct 17, 2026 Updated Oct 17, 2026 admin

password_algos returns the password-hashing algorithms currently supported by the runtime, including registered algorithm identifiers.

The examples explain the data format, expected results and the difference between this API and nearby cryptographic operations.

What It Does


The operation is intended for: password_algos returns the password-hashing algorithms currently supported by the runtime, including registered algorithm identifiers.

Part of core PHP or a normally bundled standard extension; check your deployment configuration.

Syntax and Return Value


password_algos(): array

This API accepts no required parameters, or its signature must be checked on the target runtime.

The declared return type is shown above. Errors can include false results or exceptions depending on this API: Never store plaintext passwords or compare password hashes with ==; salts and hash algorithm metadata belong in the stored hash.

Example 1: Basic Operation


Inspect the expected result: do not print secrets or reuse illustrative credentials in production.

<?php
var_dump(in_array(PASSWORD_BCRYPT, password_algos(), true));

Example 2: A Different Use Case


Inspect available algorithms rather than assuming a requested identifier exists.

<?php
// Check the alternative case.
var_dump(password_algos());

Practical Example: Checking the Result


Inspect available algorithms rather than assuming a requested identifier exists.

<?php
// Verify the expected behavior before using results.
echo count(password_algos());

Important Behavior and Edge Cases


Never store plaintext passwords or compare password hashes with ==; salts and hash algorithm metadata belong in the stored hash.

Never store plaintext passwords or compare password hashes with ==; salts and hash algorithm metadata belong in the stored hash.

Comparison with Related Functions


ApproachKey distinction
password_algospassword_algos returns the password-hashing algorithms currently supported by the runtime, including registered algorithm identifiers.
Related techniquepassword_hash and password_verify are the preferred pair for new PHP password authentication.

Common Beginner Mistakes


MistakeCorrect approach
Confusing this operation with a neighboring cryptographic or security mechanismpassword_hash and password_verify are the preferred pair for new PHP password authentication.
Ignoring a security prerequisite or failure caseNever store plaintext passwords or compare password hashes with ==; salts and hash algorithm metadata belong in the stored hash.

Key Takeaways


  • password_algos returns the password-hashing algorithms currently supported by the runtime, including registered algorithm identifiers.
  • Never store plaintext passwords or compare password hashes with ==; salts and hash algorithm metadata belong in the stored hash.
  • password_hash and password_verify are the preferred pair for new PHP password authentication.

Apply this behavior to a real application only after confirming the required extension, configuration and failure handling on the deployment runtime.

Share this resourceSend this page to someone who may find it useful.