返回資源(resource)型別

get_resource_type

(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)

get_resource_type 返回資源(resource)型別

描述

get_resource_type(resource $handle): string

此函式返回一個字串,用於表示傳遞給它的 resource 的型別。如果參數不是合法的 resource,將產生錯誤。

<?php
$c 
mysql_connect();
echo 
get_resource_type($c)."\n";
// 列印:mysql link

$fp fopen("foo","w");
echo 
get_resource_type($fp)."\n";
// 列印:file

$doc new_xmldoc("1.0");
echo 
get_resource_type($doc->doc)."\n";
// 列印:domxml document
?>

Leave a Reply

Your email address will not be published. Required fields are marked *