file

(PHP 3, PHP 4 )

file -- 파일전체를 배열로 읽어들임

Description

array file ( string filename [, int use_include_path])

file()이 파일을 배열로 반환하는 것을 제외하고는 readfile()과 같습니다. 새로운 라인이 연결되는 것을 포함해서 배열의 매 요소는 파일의 라인과 비슷합니다.

파일에서 include_path에서 파일을 찾고 싶다면 두번째 매개변수로 "1"을 사용하면 됩니다.

<?php
// 배열로 웹 페이지를 가져오고 출력함
$fcontents = file ('http://www.php.net');
while (list ($line_num, $line) = each ($fcontents)) {
    echo "<b>Line $line_num:</b> " . htmlspecialchars ($line) . "<br>\n";
}

//문자열로 웹 페이지를 가져옴
$fcontents = join ('', file ('http://www.php.net'));
?>

참조: readfile(), fopen(), fsockopen(), 그리고 popen().