Variable handling 函数
PHP 手册

is_buffer

(PHP 6 >= 6.0.0)

is_bufferFinds whether a variable is a native unicode or binary string

说明

bool is_buffer ( mixed $var )

Finds whether the given variable is a native unicode or binary string.

参数

var

The variable being evaluated.

返回值

Returns TRUE if var is a native unicode or binary string, FALSE otherwise.

范例

Example #1 is_buffer() example

<?php
// Declare some variables with different types
$types = array(
            
'unicode'    => 'Unicode string'
            
'binary'    => b'Binary string'
            
'resource'    => fopen('php://stdin''r'), 
            
'integer'    => 42
            
);

// Test which types thats a buffer
foreach($types as $type => $value)
{
    if(
is_buffer($value))
    {
        echo 
$type ' is a either a unicode or binary string';
    }
    else
    {
        echo 
$type ' is not a buffer value';
    }

    echo 
PHP_EOL;
}
?>

上例将输出:

unicode is a either a unicode or binary string
binary is a either a unicode or binary string
resource is not a buffer value
integer is not a buffer value

参见


Variable handling 函数
PHP 手册