best password hash php code example
Example 1: php hash password
$password = 'my secret password';
$hash = password_hash($password, PASSWORD_DEFAULT);
Example 2: php hash password
$host = 'localhost';
$user = 'myUser';
$passwd = 'myPasswd';
$schema = 'mySchema';
$pdo = NULL;
$dsn = 'mysql:host=' . $host . ';dbname=' . $schema;
try
{
$pdo = new PDO($dsn, $user, $passwd);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e)
{
echo 'Database connection failed.';
die();
}