note 124904 added to language.oop5.object-comparison

From: Date: Sun, 12 Apr 2020 16:19:08 +0000
Subject: note 124904 added to language.oop5.object-comparison
Groups: php.notes 
Request: Send a blank email to php-notes+get-214462@lists.php.net to get a copy of this message
Please use this corrected version of function "valuesAreIdentical" instead of that which I previously posted (dependencies found in previous post); if an Admin can just replace the fn snippet, awesome/thanks, otherwise, apologies. <?php public static function valuesAreIdentical($v1, $v2):bool{ $type1 = gettype($v1); $type2 = gettype($v2); switch(true){ case ($type1 !== $type2): return false; case ($type1==='boolean' || $type1==='integer' || $type1==='double' || $type1==='string'): //Do strict comparison here. return ($v1===$v2); case ($type1==='array'): return self::arraysAreIdentical($v1, $v2); case ($type1==='object'): return self::objectsAreIdentical($v1,$v2); case ($type1==='NULL'): //Since both types were of type NULL, consider their "values" equal. return true; case ($type1==='resource' || $type1==='unknown type'): //How to compare if at all? return true; default: return true; //Code-flow not intended to arrive here. } //end switch } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 38.142.137.34 (proxied: 96.61.135.240) ---- Manual Page -- http://php.net/manual/en/language.oop5.object-comparison.php Edit -- https://master.php.net/note/edit/124904 Del: integrated -- https://master.php.net/note/delete/124904/integrated Del: useless -- https://master.php.net/note/delete/124904/useless Del: bad code -- https://master.php.net/note/delete/124904/bad+code Del: spam -- https://master.php.net/note/delete/124904/spam Del: non-english -- https://master.php.net/note/delete/124904/non-english Del: in docs -- https://master.php.net/note/delete/124904/in+docs Del: other reasons-- https://master.php.net/note/delete/124904 Reject -- https://master.php.net/note/reject/124904 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214462) next »