PHP fopen() 函数用法及示例 - PHP教程

由网友 大卫 发布 阅读 2

PHP fopen() 函数用法及示例 - PHP教程

PHP Filesystem 参考手册

fopen()函数可以打开文件或URL。如果fopen()失败,则它可以返回false和失败错误。我们可以通过在函数名称前面添加“ @”来隐藏错误输出。

语法

resource fopen ( string $filename , string $mode [, bool $use_include_path = FALSE [, resource $context ]] )

fopen()函数可以将文件名指定的命名资源绑定到流。

在线示例

<?php
   $file = fopen("/PhpProject/sample.txt", "r");
   $file = fopen("/PhpProject/index.php", "r");
   $file = fopen("/PhpProject/sample1.txt", "wb");
?>

PHP Filesystem 参考手册

PHP ftruncate() PHP ftell()