(Unknown)
Phar::addFromString — 锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷式锟斤拷锟揭伙拷锟斤拷募锟斤拷锟� phar 锟斤拷锟斤拷
$localname
, string $contents
) : voidNote:
锟剿凤拷锟斤拷锟斤拷要 锟斤拷 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
}
?>