|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-10-12 11:01 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2020-10-12 11:01 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 07:00:01 2025 UTC |
Description: ------------ the current HashContext only has a procedural interface, some people would prefer having an Object-oriented interface instead. (the same way mysqli_query() & co has both a procedural and object-oriented api) for example, the current way to hash $str1 and $str2 is: $hc = hash_init("SHA1"); hash_update($hc, $str1); hash_update($hc, $str2); $result = hash_final($hc); (i've omitted error-checking for brevity) but if we had an OO interface, it could also be written as: $result = (new HashContext("SHA1"))->update($str1)->update($str2)->final(); some people would prefer that. something like this: https://3v4l.org/lXd3u Test script: --------------- <?php $str1 = "foo"; $str2 = "bar"; $result = (new HashContext("SHA1"))->update($str1)->update($str2)->final(); echo $result; Expected result: ---------------- 8843d7f92416211de9ebb963ff4ce28125932878