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
since: '8.5',message: "use method SplObjectStorage::offsetUnset() instead",)]
public function SplObjectStorage::detach(object
$object): voidRemoves the object from the storage.
返回值
没有返回值。
更新日志
| 版本 | 说明 |
|---|---|
| 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
来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。
