पीएचपी fgets () समारोह
❮ पीएचपी फाइल सिस्टम संदर्भउदाहरण
खुली फ़ाइल से एक पंक्ति पढ़ें:
<?php
$file = fopen("test.txt","r");
echo fgets($file);
fclose($file);
?>
परिभाषा और उपयोग
fgets () फ़ंक्शन एक खुली फ़ाइल से एक पंक्ति देता है।
वाक्य - विन्यास
fgets(file, length)
पैरामीटर मान
Parameter | Description |
---|---|
file | Required. Specifies the open file to return a line from |
length | Optional. Specifies the number of bytes to read. Reading stops when length-1 bytes have been reached, or when a new line occurs, or on EOF. If no length is specified, it reads until end of the line |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | सफलता पर फ़ाइल से पढ़ी गई एक पंक्ति, EOF या त्रुटि पर FALSE |
---|---|
पीएचपी संस्करण: | 4.0+ |
बाइनरी सुरक्षित: | हाँ, PHP 4.3 . में |
और ज्यादा उदाहरण
उदाहरण
ओपन फाइल पढ़ें, लाइन दर लाइन:
<?php
$file = fopen("test.txt","r");
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>
❮ पीएचपी फाइल सिस्टम संदर्भ