Menu Home

stream_get_line

osbo.com | PHP | Functions | stream_get_line

Gets line from stream resource up to a given delimiter

Syntax

stream_get_line ( resource $handle , int $length [, string $ending ] ) : string

Parameters

handle

A valid file handle.

length

The number of bytes to read from the handle.

ending

An optional string delimiter.

Return

Returns a string of up to length bytes read from the file pointed to by handle.

If an error occurs, returns FALSE.

Examples

handle length

<?

$filename = "https://osbo.com";
$mode = "r";

$handle = fopen($filename, $mode);

    $length = 16;

    $return = stream_get_line($handle, $length);

    echo $return;

fclose($handle);

?>
<!doctype html>

ending

<?

$filename = "https://osbo.com";
$mode = "r";

$handle = fopen($filename, $mode);

    $length = 1024;
    $ending = "\n";

    $return = stream_get_line($handle, $length, $ending);

    echo $return;

fclose($handle);

?>
<!doctype html>

PHP