PHP password_verify() 函数

PHP 教程 · 2019-01-31 23:43:36

password_verify() 函数用于验证密码是否和散列值匹配。

PHP 版本要求: PHP 5 >= 5.5.0, PHP 7

语法

bool password_verify ( string $password , string $hash )

参数说明:

  • password: 用户的密码。
  • hash: 一个由 password_hash() 创建的散列值。

返回值

如果密码和散列值匹配则返回 TRUE,否则返回 FALSE 。

实例

password_verify() 用法

<?php // 想知道以下字符从哪里来,可参见 password_hash() 的例子 $hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq'; if (password_verify('rasmuslerdorf', $hash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; } ?>

输出结果为:

Password is valid!

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

Letting Go of the Words

Letting Go of the Words

Janice (Ginny) Redish / Morgan Kaufmann / 2007-06-11 / USD 49.95

"Redish has done her homework and created a thorough overview of the issues in writing for the Web. Ironically, I must recommend that you read her every word so that you can find out why your customer......一起来看看 《Letting Go of the Words》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具