PHP fpassthru() फ़ंक्शन

परिभाषा और उपयोग

fpassthru() फ़ंक्शन फ़ाइल सूचकांक के स्थान पर सभी शेष डाटा निकालता है

यह फ़ंक्शन दिए गए फ़ाइल सूचकांक को वर्तमान स्थान से EOF तक पढ़ता है और परिणाम को आउटपुट बफ़र में लिखता है

व्याकरण

fpassthru(file)
पारामीटर वर्णन
file आवश्यक। खुला फ़ाइल या संसाधन को निर्दिष्ट करता है

व्याख्या

यदि गलती होती है, fpassthru() false वापस करता है। अन्यथा fpassthru() से वापस किया जाता है file पढ़ा और निकाले गए चारित्रों की संख्या देखा जाता है

फ़ाइल सूचकांक मान्य होना चाहिए और उसे एक खुले फ़ाइल या संसाधन की ओर इंगित करना चाहिए fopen() या fsockopen() सफलता से खोला है (लेकिन अभी तक इसे नहीं इस्तेमाल किया गया है) fclose() to close) the file.

Tips and comments

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

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

कमेंटर:When using fpassthru() with binary files on Windows systems, make sure that the b is added in the mode when opening the file with fopen() to open the file in binary mode. Encouraged to use the b flag when handling binary files, even if the system does not need it, as this can make the script more portable.

सामान्य

उदाहरण 1

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

आउटपुट:

This file में तीन पंक्तियाँ हैं.
This is the last line.59

नोट:59 निर्देश भेजे गए चारकियों की संख्या

उदाहरण 2

डाउनलोड www सर्वर की index पृष्ठ को ट्रांसफर करें:

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