get_resource_type() 函數是 PHP 中的內置函數,用於返回資源類型。
用法:
get_resource_type(resource $resource)
Parameters: 該函數接受一個如下所述的參數:
- $resource: 該參數指定評估的資源句柄名稱。
返回值:如果給定資源是資源,則該函數將返回表示其類型的字符串。如果該函數無法確定資源的類型,它將返回Unknown。
示例 1:在下麵的示例中,我們將使用以下命令打印資源類型get_resource_type()函數。
PHP
<?php
$file_text = fopen("text.txt","rb") ;
echo get_resource_type($file_text) ;
?>
輸出:
stream
示例 2:在下麵的示例中,當您使用 get_resource_type() 函數而不向該函數傳遞任何資源時,將打印 Unknown。
PHP
<?php
$file_text = fopen("text.txt","rb") ;
echo get_resource_type($file_text)."\n" ;
fclose($file_text);
echo get_resource_type($file_text) ;
?>
輸出:
stream Unknown
參考: https://www.php.net/manual/en/function.get-resource-type.php
相關用法
- PHP get_resource_type()用法及代碼示例
- PHP get_resource_id()用法及代碼示例
- PHP get_resources()用法及代碼示例
- PHP get_class_vars()用法及代碼示例
- PHP get_declared_interfaces()用法及代碼示例
- PHP get_parent_class()用法及代碼示例
- PHP get_meta_tags()用法及代碼示例
- PHP get_html_translation_table()用法及代碼示例
- PHP get_browser()用法及代碼示例
- PHP get_defined_vars()用法及代碼示例
- PHP get_headers()用法及代碼示例
- PHP get_class()用法及代碼示例
- PHP get_class_methods()用法及代碼示例
- PHP get_called_class()用法及代碼示例
- PHP get_object_vars()用法及代碼示例
- PHP get_declared_classes()用法及代碼示例
- PHP get_included_files()用法及代碼示例
- PHP get_current_user()用法及代碼示例
- PHP get_defined_functions()用法及代碼示例
- PHP get_mangled_object_vars()用法及代碼示例
- PHP get_include_path()用法及代碼示例
- PHP get_defined_constants()用法及代碼示例
- PHP get_loaded_extensions()用法及代碼示例
- PHP getrandmax()用法及代碼示例
- PHP getcwd()用法及代碼示例
注:本文由純淨天空篩選整理自neeraj3304大神的英文原創作品 PHP get_resource_type() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。