Home  >  Article  >  Backend Development  >  PHP file() function_PHP tutorial

PHP file() function_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:00:351031browse

PHP file() function I used the file function to write a WEB anti-virus program before. In fact, file directly reads a txt file and saves it into an array. Then I think you also know what it does. Well, file reads a file by putting the first line in the txt file into the array. ​

PHP file() function I used the file function to write a WEB anti-virus program before. In fact, file directly reads a txt file and saves it into an array. Then I think you also know its function. What is it? File reads a file by putting the first line in the txt file into an array

Syntax:

Definition and usage
The file() reads a file into an array.

Each array element is contained from the file, with newlines still valued.

Grammar

file(path,include_path,context)

		Parameter
Description
path 文件路径
include_path 任择。将此参数设置为'1 '如果你想搜寻档案中的include_path中(在php.ini中) ,以及
context 任择。指定范围内的档案处理。背景是一组选项,可以修改的行为流。可以跳过用空。
Description
path File path
include_path Optional. Set this parameter to '1' if you want to search files in include_path (in php.ini), and
context Optional. File processing within a specified range. A context is a set of options that can modify the flow of behavior. Can be skipped with empty space.


Tips and Instructions Tip: This feature becomes binary safe in PHP 4.3. (Meaning that both binary data such as image and character data can be written to this function). -------------------------------------------------- ------------------------------- For example

print_r(file("test.txt"));?>

Output.

Array([0] => a
[1] => b.[2] => c,[3] => d?)


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445504.htmlTechArticlePHP file() function I used the file function to write a WEB anti-virus program before. In fact, it is just file. txt file is directly read and saved into an array, then I think you also know how it works...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn