Example 1 — Check That bcrypt Is Available
Look for the bcrypt ID in the list.
<?php
$algos = password_algos();
if (in_array('2y', $algos, true)) {
echo "bcrypt is available", PHP_EOL;
} How It Works
- Call the function.
password_algos()returns an array of strings. - Search the array.
in_array()looks for2y, the bcrypt ID. - Use strict mode. The third argument
truecompares types too. - Print a message. bcrypt is always built in, so this always runs.

