PHP 파일 () 함수
정의 및 사용
파일 () 함수는 배열로 전체 파일을 읽습니다.
배열의 각 요소가 포함 된 줄 바꿈을 포함하여 한 행에 파일입니다.
문법
file(path,include_path,context)
参数 | 描述 |
---|---|
path | 必需。规定要读取的文件。 |
include_path | 可选。如果您还想在 include_path(在 php.ini 中)中搜索文件的话,请设置该参数为 '1'。 |
context | 可选。规定文件句柄的环境。context 是一套可以修改流的行为的选项。若使用 NULL,则忽略。 |
팁과주의 사항
팁 : PHP 4.3으로,이 함수는 바이너리 안전합니다.(바이너리 이미지와 같은 데이터 () 및 문자 데이터를 작성하는이 기능을 사용할 수 있음을 의미.)
예
<?php
print_r(file("test.txt"));
?>
print_r(file("test.txt"));
?>
가 출력 위의 코드 :
Array
(
[0] => Hello World. Testing testing!
[1] => Another day, another line.
[2] => If the array picks up this line,
[3] => then is it a pickup line?
)
(
[0] => Hello World. Testing testing!
[1] => Another day, another line.
[2] => If the array picks up this line,
[3] => then is it a pickup line?
)
PHP 파일 시스템 참조 설명서를 완료