= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)hash_final — 結束增量哈希,并且返回摘要結果說明hash_final(HashContext $context, bool $raw_output = false): st">

hash_final

(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)

hash_final結束增量哈希,并且返回摘要結果

說明

hash_final(HashContext $context, bool $raw_output = false): string

參數

context

hash_init() 函數返回的哈希運算上下文資源。

raw_output

設置為 true,輸出格式為原始的二進制數據。 設置為 false,輸出小寫的 16 進制字符串。

返回值

如果 raw_output 設置為 true, 則返回原始二進制數據表示的信息摘要, 否則返回 16 進制小寫字符串格式表示的信息摘要。

更新日志

版本 說明
7.2.0 接收參數從資源類型修改為 HashContext 對象類型。

范例

示例 #1 hash_final() 例程

<?php
$ctx 
hash_init('sha1');
hash_update($ctx'The quick brown fox jumped over the lazy dog.');
echo 
hash_final($ctx);
?>

以上例程會輸出:

c0854fb9fb03c41cce3802cb0d220529e6eef94e

參見