PHP fopen() 函数
PHP 教程
· 2019-01-25 06:58:02
定义和用法
fopen() 函数打开一个文件或 URL。
如果 fopen() 失败,它将返回 FALSE 并附带错误信息。您可以通过在函数名前面添加一个 '@' 来隐藏错误输出。
语法
fopen(filename,mode,include_path,context)
| 参数 | 描述 |
|---|---|
| filename | 必需。规定要打开的文件或 URL。 |
| mode | 必需。规定您请求到该文件/流的访问类型。 可能的值:
|
| include_path | 可选。如果您还想在 include_path(在 php.ini 中)中搜索文件的话,请设置该参数为 '1'。 |
| context | 可选。规定文件句柄的环境。context 是一套可以修改流的行为的选项。 |
提示和注释
注释:当书写一个文本文件时,请确保您使用了正确的行结束符!在 Unix 系统中,行结束符为 \n;在 Windows 系统中,行结束符为 \r\n;在 Macintosh 系统中,行结束符为 \r。Windows 系统中提供了一个文本转换标记 "t" ,可以透明地将 \n 转换为 \r\n。您还可以使用 "b" 来强制使用二进制模式,这样就不会转换数据。为了使用这些标记,请使用 "b" 或者 "t" 来作为 mode 参数的最后一个字符。
实例
<?php
$file = fopen("test.txt","r");
$file = fopen("/home/test/test.txt","r");
$file = fopen("/home/test/test.gif","wb");
$file = fopen("http://www.example.com/","r");
$file = fopen("ftp://user:password@example.com/test.txt","w");
?>
点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html
Data Structures and Algorithms
Alfred V. Aho、Jeffrey D. Ullman、John E. Hopcroft / Addison Wesley / 1983-1-11 / USD 74.20
The authors' treatment of data structures in Data Structures and Algorithms is unified by an informal notion of "abstract data types," allowing readers to compare different implementations of the same......一起来看看 《Data Structures and Algorithms》 这本书的介绍吧!