Phar::addFromString

(Unknown)

Phar::addFromString锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷式锟斤拷锟揭伙拷锟斤拷募锟斤拷锟� phar 锟斤拷锟斤拷

说锟斤拷

public Phar::addFromString ( string $localname , string $contents ) : void

Note:

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

通锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷魏锟斤拷址锟斤拷锟斤拷锟斤拷锟斤拷员锟斤拷锟接碉拷 phar 锟斤拷锟斤拷锟叫★拷 锟侥硷拷锟斤拷锟斤拷锟斤拷 localname 为路锟斤拷锟斤拷锟芥到锟斤拷锟斤拷锟叫★拷 锟斤拷锟斤拷锟斤拷锟斤拷锟� ZipArchive::addFromString() 锟斤拷锟狡★拷

锟斤拷锟斤拷

localname

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

contents

要锟斤拷锟斤拷锟斤拷募锟斤拷锟斤拷荨锟�

锟斤拷锟斤拷值

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

锟斤拷锟斤拷

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

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

    
$a->addFromString('path/to/file.txt''my simple file');
    
$b $a['path/to/file.txt']->getContent();

    
// to add contents from a stream handle for large files, use offsetSet()
    
$c fopen('/path/to/hugefile.bin');
    
$a['largefile.bin'] = $c;
    
fclose($c);
} catch (
Exception $e) {
    
// handle errors here
}
?>

锟轿硷拷

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