Removes an object from the storage

# SplObjectStorage::detach

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

SplObjectStorage::detach — Removes an object from the storage

警告

此函数自 PHP 8.5.0 起弃用。强烈建议不要应用此函数。

### 说明

#[\Deprecated]
public function SplObjectStorage::detach(object `$object`): void

Removes the object from the storage.

### 参数

`object`

  The object to remove.

### 返回值

没有返回值。

### 更新日志

版本 | 说明
--- | ---
8.5.0 | This method has been deprecated in favor of SplObjectStorage::offsetUnset().

### 示例

示例 #1 SplObjectStorage::detach() example

    <?php
    $o = new stdClass;
    $s = new SplObjectStorage();
    $s->attach($o);
    var_dump(count($s));
    $s->detach($o);
    var_dump(count($s));
    ?>

以上示例的输出类似于：

    int(1)
    int(0)

### 参见

- SplObjectStorage::attach() - Adds an object in the storage
- SplObjectStorage::removeAll() - Removes objects contained in another storage from the current storage

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open