Identical to readfile(), except that file() returns the file in an array. Each element of the array corresponds to a line in the file, with the newline still attached. Upon failure, file() returns FALSE.
You can use the optional use_include_path parameter and set it to "1", if you want to search for the file in the include_path, too.
<?php |
Tipp: URL-t is megadhatsz az állomány név paraméter helyén ha a fopen wrappers szolgáltatás be van kapcsolva. Bővebb információk az fopen() leírásánál olvashatóak arról, milyen módon adhatod meg a fájlneveket, valamint érdemes megtekinteni a L Függelék oldalt a támogatott URL típusok listájának megtekintése gyanánt.
Megjegyzés: Each line in the resulting array will include the line ending, so you still need to use rtrim() if you do not want the line ending present.
Megjegyzés: Ha problémád akadna PHP-ben Machintosh gépen létrehozott szöveges fileokban a sorvégek olvasásával, valószínűleg be kell kapcsolnod az auto_detect_line_endings beállítást.
Megjegyzés: As of PHP 4.3.0 you can use file_get_contents() to return the contents of a file as a string.
In PHP 4.3.0 file() became binary safe.
Megjegyzés: Context support was added with PHP 5.0.0.
Figyelem |
Bizonyos, nem teljesen szabványkövető webszerverek - mint például az IIS - olyan módon képesek az adat továbbítására, ami a PHP-t warning jellegű hibaüzenetek kiadására késztetik. Ilyen szerverek esetén érdemes az error_reporting értéket lejjebb venni, hogy ne jelenjenek meg ezek a fajta hibaüzenetek. |
See also readfile(), fopen(), fsockopen(), popen(), file_get_contents(), and include().