PHP fpassthru() ফাংশন

অর্থনীতি ও প্রয়োগ

fpassthru() ফাংশন ফাইল ইন্ডেক্সের স্থানের সকল বাকি ডাটা রিটার্ন করে。

এই ফাংশন প্রদেয় ফাইল ইন্ডেক্সকে বর্তমান স্থান থেকে EOF-এ পড়া এবং ফলাফলকে আউটপুট বাফারে লিখে দেয়。

সিন্থেক্স

fpassthru(ফাইল)
পারামিটার বর্ণনা
ফাইল বাধ্যতামূলক। নির্দিষ্ট করা হওয়া ফাইল বা রিসোর্সকে

ব্যাখ্যা

যদি ত্রুটি হয়, তবে fpassthru() এফসলুস রিটার্ন করে। না তবে fpassthru() এফসলুস রিটার্ন করে থাকে থেকে ফাইল পড়া এবং যে কোনো আউটপুটে পাঠানো হওয়ার অক্ষর সংখ্যা。

ফাইল ইন্ডেক্স বাধ্যতামূলক, এবং এটা একটি ফাইলের ফপেন() কিন্তু এটা ফসকওপেন() সফলভাবে খোলা হয়েছে (কিন্তু এটা এখনও ব্যবহার করা হয়নি) fclose() the file that is closed ()。

Tips and Comments

Tip:If you have already written data to the file, you must call rewind() to point the file pointer to the beginning of the file.

Tip:If you do not modify the file or retrieve at a specific location, but just want to download the content of the file to the output buffer, you should use readfile()This can save the fopen() call.

Comment:When using fpassthru() with binary files on Windows systems, make sure to add b to the mode when opening the file with fopen() to open the file in binary mode. It is encouraged to use the b flag when handling binary files, even if the system does not need it, so that the script has better portability.

Instance

Example 1

<?php
$file = fopen("test.txt","r");
// Read the first line
fgets($file);
// Send the remaining part of the file to the output buffer
echo fpassthru($file);
fclose($file);
?>

Output:

There are three lines in this file.
This is the last line.59

Note:59 indicates the number of characters passed.

Example 2

Dump the index page of www server:

<?php
$file = fopen("http://www.example.com","r");
fpassthru($file);
?>