hash_copy()
hash_copy() — Copy hashing context.
Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.3.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
Signature
hash_copy(HashContext $context): HashContext
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $context | HashContext | Hashing context returned by hash_init(). |
Return value
Returns a copy of Hashing Context.
Example
A runnable snippet:
$context = hash_init("sha256"); hash_update($context, "The quick brown fox "); /* copy context to be able to continue using it */ $copy_context = hash_copy($context); echo hash_final($context), "\n"; hash_update($copy_context, "jumped over the lazy dog."); echo hash_final($copy_context), "\n";
Output:
b29d66e56ed90cce9b0165c43fedec612b60a071974d8be4513e18580d55b5bd 68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
Changelog
| Version | Change |
|---|---|
| 7.2.0 | Accept and return HashContext instead of resource. |
All PHP 8.5 built-in functions
Reference card built from the PHP manual page hash_copy() (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.