readfile

(PHP 4, PHP 5, PHP 7)

readfile锟斤拷锟斤拷募锟�

说锟斤拷

readfile ( string $filename [, bool $use_include_path = false [, resource $context ]] ) : int

锟斤拷取锟侥硷拷锟斤拷写锟诫到锟斤拷锟斤拷锟斤拷濉�

锟斤拷锟斤拷

filename

要锟斤拷取锟斤拷锟侥硷拷锟斤拷锟斤拷

use_include_path

锟斤拷要锟斤拷 include_path 锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷锟斤拷使锟斤拷锟斤拷锟斤拷锟窖★拷牡诙锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟轿� TRUE锟斤拷

context

Stream 锟斤拷锟斤拷锟侥o拷context锟斤拷 resource锟斤拷

锟斤拷锟斤拷值

锟斤拷锟截达拷锟侥硷拷锟叫讹拷锟斤拷锟斤拷纸锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 FALSE 锟斤拷锟揭筹拷锟斤拷锟斤拷锟斤拷 @readfile() 锟斤拷式锟斤拷锟矫o拷锟斤拷锟斤拷锟斤拷锟绞撅拷锟斤拷锟斤拷锟较拷锟�

锟斤拷锟斤拷

Example #1 使锟斤拷 readfile() 强锟斤拷锟斤拷锟斤拷

<?php
$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('Expires: 0');
    
header('Cache-Control: must-revalidate');
    
header('Pragma: public');
    
header('Content-Length: ' filesize($file));
    
readfile($file);
    exit;
}
?>

锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�

锟斤拷 / 锟斤拷锟斤拷曰锟斤拷锟�

注锟斤拷

Note:

readfile() 锟斤拷锟斤拷锟结导锟斤拷锟轿猴拷锟节达拷锟斤拷锟解。 锟斤拷锟斤拷锟斤拷锟斤拷诖娌伙拷锟侥达拷锟斤拷使锟斤拷 ob_get_level() 确锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷丫锟斤拷乇铡锟�

Tip

锟斤拷锟斤拷锟斤拷锟斤拷fopen 锟斤拷装锟斤拷锟斤拷锟节此猴拷锟斤拷锟叫o拷 URL 锟斤拷锟斤拷为锟侥硷拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟街革拷锟斤拷募锟斤拷锟斤拷锟斤拷 fopen()锟斤拷锟斤拷锟斤拷 wapper 锟侥诧拷同锟斤拷锟斤拷锟斤拷渭锟� 支锟街碉拷协锟斤拷头锟阶靶拷锟�锟斤拷注锟斤拷锟斤拷锟矫凤拷锟斤拷锟斤拷锟斤拷峁╋拷锟皆わ拷锟斤拷锟斤拷锟斤拷锟斤拷

Note: 锟斤拷 PHP 5.0.0 锟斤拷锟斤拷锟斤拷锟剿讹拷锟斤拷锟斤拷锟侥o拷Context锟斤拷锟斤拷支锟街★拷锟叫癸拷锟斤拷锟斤拷锟侥o拷Context锟斤拷锟斤拷说锟斤拷锟轿硷拷 Streams锟斤拷

锟轿硷拷