표준 PHP 라이브러리(SPL) SplObjectStorage::offsetExists

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

SplObjectStorage::offsetExists — 저장소에 개체가 있는지 확인


설명

public SplObjectStorage::offsetExists(object $object): bool

저장소에 개체가 있는지 확인합니다.

메모: SplObjectStorage::offsetExists()SplObjectStorage::contains()의 별칭입니다.


매개변수

object
찾을 개체입니다.

반환 값

객체가 저장소에 있으면 true를 반환하고 그렇지 않으면 false를 반환합니다.


Examples

예제 #1 SplObjectStorage::offsetExists() 예제

                  
<?php
$s = new SplObjectStorage;
$o1 = new StdClass;
$o2 = new StdClass;

$s->attach($o1);

var_dump($s->offsetExists($o1)); // Similar to isset($s[$o1])
var_dump($s->offsetExists($o2)); // Similar to isset($s[$o2])
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

bool(true)
bool(false)
                

기타