array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.is-resource.php', 1 => 'is_resource', ), 'up' => array ( 0 => 'ref.var.php', 1 => '变量处理函数', ), 'prev' => array ( 0 => 'function.is-real.php', 1 => 'is_real', ), 'next' => array ( 0 => 'function.is-scalar.php', 1 => 'is_scalar', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/var/functions/is-resource.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
is_resource — 查找变量是否为资源
value
要计算的变量。
示例 #1 is_resource() 示例
<?php
$handle = fopen("php://stdout", "w");
if (is_resource($handle)) {
echo '$handle is a resource';
}
?>
以上示例会输出:
$handle is a resource
注意:
is_resource() 不是严格的类型检查方法:如果
value
是已关闭的资源变量,将返回false
。