पीएचपी file_get_contents () समारोह
❮ पीएचपी फाइल सिस्टम संदर्भउदाहरण
एक फ़ाइल को एक स्ट्रिंग में पढ़ें:
<?php
echo file_get_contents("test.txt");
?>
परिभाषा और उपयोग
file_get_contents() एक फ़ाइल को एक स्ट्रिंग में पढ़ता है।
यह फ़ंक्शन किसी फ़ाइल की सामग्री को स्ट्रिंग में पढ़ने का पसंदीदा तरीका है। यह मेमोरी मैपिंग तकनीकों का उपयोग करेगा, यदि यह सर्वर द्वारा समर्थित है, तो प्रदर्शन को बढ़ाने के लिए।
वाक्य - विन्यास
file_get_contents(path, include_path, context, start,
max_length)
पैरामीटर मान
Parameter | Description |
---|---|
path | Required. Specifies the path to the file to read |
include_path | Optional. Set this parameter to '1' if you want to search for the file in the include_path (in php.ini) as well |
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream. Can be skipped by using NULL. |
start | Optional. Specifies where in the file to start reading. Negative values count from the end of the file |
max_length | Optional. Specifies the maximum length of data read. Default is read to EOF |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | एक स्ट्रिंग में पूरी फ़ाइल, विफलता पर FALSE |
---|---|
पीएचपी संस्करण: | 4.3+ |
बाइनरी सुरक्षित: | हाँ, PHP 4.3 . में |
पीएचपी चेंजलॉग: | PHP 7.1 - प्रारंभ पैरामीटर में नकारात्मक मानों के लिए समर्थन PHP 5.1 - प्रारंभ और max_length पैरामीटर जोड़ा गया |
❮ पीएचपी फाइल सिस्टम संदर्भ