array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'splobjectstorage.offsetunset.php', 1 => 'SplObjectStorage::offsetUnset', 2 => 'Removes an object from the storage', ), 'up' => array ( 0 => 'class.splobjectstorage.php', 1 => 'SplObjectStorage', ), 'prev' => array ( 0 => 'splobjectstorage.offsetset.php', 1 => 'SplObjectStorage::offsetSet', ), 'next' => array ( 0 => 'splobjectstorage.removeall.php', 1 => 'SplObjectStorage::removeAll', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/spl/splobjectstorage/offsetunset.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

SplObjectStorage::offsetUnset

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

SplObjectStorage::offsetUnsetRemoves an object from the storage

Beschreibung

public SplObjectStorage::offsetUnset(object $object): void

Removes an object from the storage.

Hinweis:

SplObjectStorage::offsetUnset() is an alias of SplObjectStorage::detach().

Parameter-Liste

object

The object to remove.

Rückgabewerte

Es wird kein Wert zurückgegeben.

Beispiele

Beispiel #1 SplObjectStorage::offsetUnset() example

<?php
$o
= new stdClass;
$s = new SplObjectStorage();
$s->attach($o);
var_dump(count($s));
$s->offsetUnset($o); // Similar to unset($s[$o])
var_dump(count($s));
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

int(1)
int(0)

Siehe auch