Phar::addFile

(Unknown)

Phar::addFile锟斤拷一锟斤拷锟侥硷拷锟斤拷锟侥硷拷系统锟斤拷拥锟� phar 锟斤拷锟斤拷锟斤拷

说锟斤拷

public Phar::addFile ( string $file [, string $localname ] ) : void

Note:

锟剿凤拷锟斤拷锟斤拷要 锟斤拷 php.ini 锟叫碉拷 phar.readonly 锟斤拷为 0 锟斤拷锟绞猴拷 Phar 锟斤拷锟斤拷. 锟斤拷锟斤拷, 锟斤拷锟阶筹拷PharException.

通锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷魏锟斤拷募锟斤拷锟斤拷锟� URL 锟斤拷锟皆憋拷锟斤拷拥锟� phar 锟斤拷锟斤拷锟叫★拷锟斤拷锟斤拷诙锟斤拷锟斤拷锟窖★拷锟斤拷锟� localname 锟斤拷锟借定锟斤拷 锟斤拷么锟侥硷拷锟斤拷锟斤拷愿貌锟斤拷锟轿拷锟斤拷票锟斤拷娴斤拷锟斤拷锟斤拷校锟斤拷锟斤拷猓�file 锟斤拷锟斤拷锟结被锟斤拷为路锟斤拷锟斤拷锟斤拷锟节碉拷锟斤拷锟叫★拷 URLs 锟斤拷锟斤拷锟结交 localname 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷壮锟斤拷斐o拷锟� 锟斤拷锟斤拷锟斤拷锟斤拷锟� ZipArchive::addFile() 锟斤拷锟狡★拷

锟斤拷锟斤拷

file

锟斤拷要锟斤拷拥锟� phar 锟斤拷锟斤拷锟斤拷锟侥硷拷锟节达拷锟斤拷锟较碉拷锟斤拷全锟斤拷锟斤拷锟皆o拷锟斤拷锟斤拷锟斤拷锟铰凤拷锟斤拷锟�

localname

锟侥硷拷锟斤拷锟芥到锟斤拷锟斤拷时锟斤拷路锟斤拷锟斤拷

锟斤拷锟斤拷值

没锟叫凤拷锟斤拷值锟斤拷失锟斤拷时锟斤拷锟阶筹拷锟届常锟斤拷

锟斤拷锟斤拷

Example #1 一锟斤拷 Phar::addFile() 示锟斤拷

<?php
try {
    
$a = new Phar('/path/to/phar.phar');

    
$a->addFile('/full/path/to/file');
    
// demonstrates how this file is stored
    
$b $a['full/path/to/file']->getContent();

    
$a->addFile('/full/path/to/file''my/file.txt');
    
$c $a['my/file.txt']->getContent();

    
// demonstrate URL usage
    
$a->addFile('http://www.example.com''example.html');
} catch (
Exception $e) {
    
// handle errors here
}
?>

锟轿硷拷

  • Phar::offsetSet() - Set the contents of an internal file to those of an external file
  • PharData::addFile() - Add a file from the filesystem to the tar/zip archive
  • Phar::addFromString() - 锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷式锟斤拷锟揭伙拷锟斤拷募锟斤拷锟� phar 锟斤拷锟斤拷
  • Phar::addEmptyDir() - 锟斤拷锟揭伙拷锟斤拷锟侥柯硷拷锟� phar 锟斤拷锟斤拷