SplObjectStorage::attach
オブジェクトをストレージに追加する
&warn.deprecated.function-8-5-0;
&reftitle.description;
#[\Deprecated]
public voidSplObjectStorage::attach
objectobject
mixedinfo&null;
オブジェクトをストレージに追加し、
オプションでそれを何らかのデータに関連づけます。
このメソッドは
SplObjectStorage::offsetSet
のエイリアスです。
&reftitle.parameters;
object
追加したいオブジェクト。
info
object に関連づけるデータ。
&reftitle.returnvalues;
&return.void;
&reftitle.examples;
SplObjectStorage::attach の例
attach($o1); // $s[$o1] = NULL; と同等
$s->attach($o2, "hello"); // $s[$o2] = "hello"; と同等
var_dump($s[$o1]);
var_dump($s[$o2]);
?>
]]>
&example.outputs.similar;
&reftitle.seealso;
SplObjectStorage::detach
SplObjectStorage::offsetSet