php专区

 首页 > php专区 > PHP应用 > php函数大全 > php readfile 函数

php readfile 函数

分享到:
【字体:
导读:
          php readfile 函数readfile ( PHP 4中, PHP 5中) readfile -输出一个文件 描述 国际readfile (字符串$文件名[ ,布尔$ use_include_path =虚假[ ,资源$背景] ] ) 读取文件并写入它的输

php readfile 函数
 

readfile
( PHP 4中, PHP 5中)

readfile -输出一个文件

描述
国际readfile (字符串$文件名[ ,布尔$ use_include_path =虚假[ ,资源$背景] ] )
读取文件并写入它的输出缓冲器。

参数

文件名
该文件被读取。

use_include_path
您可以使用可选的第二个参数设置为TRUE ,如果你想搜索该文件中的include_path中也。

背景
背景流资源。


返回值
返回的字节数读取文件。如果出现错误,虚假,除非返回的功能称为@ readfile ( ) ,错误信息打印。

实例

例如# 1强迫下载使用readfile ( )

$file = 'monkey.gif';

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
?>

分享到:
php fgetcsv 函数
php fgetcsv 函数   fgetcsv ( PHP 4中, PHP 5中) fgetcsv -获取线从文件指针和解析为的CSV领域 描述 阵列fgetcsv (资源$处理[摘要$长度[ ,字符串$定界符[ ,字符串$附文[ ,字符串$逃生] ] ] ] ) 类似fgets ( ) ,但fgetcsv ( )解析行读取的领域以CSV格式并返回一个数组包含字段读取。 参数 把柄 ...
php file 函数
php file 函数   file ( PHP 4中, PHP 5中) file-读取整个file到一个数组 描述 一系列file(字符串$file[摘要$国旗= 0 [ ,资源$背景] ] ) 读取整个file到一个数组。 注:您可以使用file_get_contents ( )返回file内容作为一个字符串。 参数 file名 file路径。 提示 网址可以用来作为file名与此功能...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……