표준 PHP 라이브러리(SPL) SplObjectStorage::offsetSet
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
SplObjectStorage::offsetSet — 스토리지의 개체에 데이터 연결
설명
public SplObjectStorage::offsetSet(object $object
, mixed $info
= null
): void
스토리지의 개체에 데이터를 연결합니다.
메모: SplObjectStorage::offsetSet()은 SplObjectStorage::attach()의 별칭입니다.
매개변수
object
- 데이터를 연결할 개체입니다.
info
- 개체와 연결할 데이터입니다.
반환 값
값이 반환되지 않습니다.
Examples
예제 #1 SplObjectStorage::offsetSet() 예제
<?php
$s = new SplObjectStorage;
$o1 = new StdClass;
$s->offsetSet($o1, "hello"); // Similar to $s[$o1] = "hello";
var_dump($s[$o1]);
?>
위의 예는 다음과 유사한 결과를 출력합니다.
string(5) "hello"
기타
- SplObjectStorage::attach() - 저장소에 개체를 추가합니다.
- SplObjectStorage::offsetGet() - 객체와 관련된 데이터를 반환
- SplObjectStorage::offsetExists() - 저장소에 개체가 있는지 확인
- SplObjectStorage::offsetUnset() - 저장소에서 개체를 제거합니다.