hash_update_file()

hash_update_file() — Pump data into an active hashing context from a file.

Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

hash_update_file(HashContext $context, string $filename, ?resource $stream_context = null): bool

Parameters

ParameterTypeWhat it takes
$contextHashContextHashing context returned by hash_init().
$filenamestringURL describing location of file to be hashed; Supports fopen() wrappers.
$stream_context?resourceStream context as returned by stream_context_create().

Return value

Returns true on success or false on failure.

Example

The PHP manual ships no example for hash_update_file(); the signature and the parameter table above are the contract.

Changelog

VersionChange
8.0.0stream_context is now nullable.
7.2.0Accept HashContext instead of resource.

See also

hash_init(), hash_update(), hash_update_stream(), hash_final(), hash_file()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page hash_update_file() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.