SplObjectStorage::detach
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
Removes an object from the storage
Function-8-5-0
Description
SplObjectStorage::detach(object $object): void
Removes the object from the storage.
Parameters
objectThe
objectto remove.
Return Values
Void
Changelog
| Version | Description |
|---|---|
| 8.5.0 | This method has been deprecated in favor of SplObjectStorage::offsetUnset. |
Examples
SplObjectStorage::detach() example
php
<?php
$o = new stdClass;
$s = new SplObjectStorage();
$s->attach($o);
var_dump(count($s));
$s->detach($o);
var_dump(count($s));
?>The above example will output something similar to:
output
int(1)
int(0)See Also
SplObjectStorage::attachSplObjectStorage::removeAll