PHP 8.5.0 Beta 2 available for testing

Voting

: six minus zero?
(Example: nine)

The Note You're Voting On

aron dot duby at gmail dot com
12 years ago
This also appears to be the function which gets used within the contains() function, so if all the objects you are storing already have a unique id you can overwrite this function with your own class.

<?php
class UserStorage extends SPLObjectStorage{
public function
getHash($obj){
return
$obj->id;
}
}

$us = new UserStorage();
$user1 = new User(1);
$user2 = new User(2);

$us->attach($user1);
$us->attach($user2);

$me = new User(2);

// the following would normally fail since they are two separate objects
// but it works now with our extended getHash()
$us->contains($me);

?>

<< Back to user notes page

To Top