변수처리 get_resource_type
(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)
get_resource_type — 리소스 유형을 반환합니다.
설명
get_resource_type(resource $resource
): string
이 함수는 주어진 리소스의 유형을 가져옵니다.
매개변수
resource
- 평가된 리소스 핸들입니다.
반환 값
주어진 resource
가 리소스인 경우 이 함수는 해당 유형을 나타내는 문자열을 반환합니다. 이 함수로 유형을 식별하지 않으면 반환 값은 Unknown
문자열이 됩니다.
이 함수는 resource
가 리소스가 아닌 경우 null
을 반환하고 오류를 생성합니다.
Examples
예제 #1 get_resource_type() 예제
<?php
$fp = fopen("foo", "w");
echo get_resource_type($fp) . "\n";
// As of PHP 8.0.0, the following does not work anymore. The curl_init function returns a CurlHandle object now.
$c = curl_init();
echo get_resource_type($c) . "\n";
?>
PHP 7에서 위 예제의 출력:
stream curl
기타
- get_resource_id() - 주어진 리소스에 대한 정수 식별자를 반환합니다.