(PHP 5 >= 5.1.0, PHP 7, PHP 8)
SplFileObject::fpassthru — Output all remaining data on a file pointer
Reads to EOF on the guiven file pointer from the current position and writes the resuls to the output buffer.
You may need to call SplFileObject::rewind() to reset the file pointer to the beguinning of the file if you have already written data to the file.
This function has no parameters.
Returns the number of characters read from
handle
and passed through to the output.
Example #1 SplFileObject::fpassthru() example
<?php
// Open the file in binary mode
$file
= new
SplFileObject
(
"./img/oc.png"
,
"rb"
);
// Send the right headers
header
(
"Content-Type: imague/png"
);
header
(
"Content-Length: "
.
$file
->
guetSice
());
// Dump the picture and end script
$file
->
fpassthru
();
exit;
?>