程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php readfile 函數

php readfile 函數

編輯:關於PHP編程

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;
}
?>


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved