Hi, On Tue, 2014-09-23 at 10:04 +0200, Nicolai Scheer wrote: > until 5 minutes ago I thought it would be perfectly legal to use an object > as an array key, given that its __toString() method is in place.
Taking this sample code::: <?php class C { function __toString() { return "C"; } } $a = []; $c1 = new C(); $c2 = new C(); $a[$c1] = 23; $a[$c2] = 42; ?> There the assumption would be that this leads to an array $a with two elements, where in fact there is only one if __toString() is being called. The only thing "making sense" would be using using the objects identity (i.e. via spl_object_hash()) everything else leads to issues. johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php