PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ZipArchive::close> <ZipArchive::addFile
Last updated: Fri, 29 Aug 2008

view this page in

ZipArchive::addFromString

(No version information available, might be only in CVS)

ZipArchive::addFromStringその内容を指定して、ファイルを ZIP アーカイブに追加する

説明

bool ZipArchive::addFromString ( string $localname , string $contents )

その内容を指定して、ファイルを ZIP アーカイブに追加します。

パラメータ

localname

作成するエントリの名前。

contents

エントリを作成するために使用するデータの内容。 バイナリセーフな形式で使用されます。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例1 新しいアーカイブへのエントリの追加

<?php
$zip 
= new ZipArchive;
$res $zip->open('test.zip'ZipArchive::CREATE);
if (
$res === TRUE) {
    
$zip->addFromString('test.txt''ここにファイルの内容を書きます');
    
$zip->close();
    echo 
'成功';
} else {
    echo 
'失敗';
}
?>

例2 アーカイブ内のディレクトリへのファイルの追加

<?php
$zip 
= new ZipArchive;
if (
$zip->open('test.zip') === TRUE) {
    
$zip->addFromString('dir/test.txt''ここにファイルの内容を書きます');
    
$zip->close();
    echo 
'成功';
} else {
    echo 
'失敗';
}
?>


add a note add a note User Contributed Notes
ZipArchive::addFromString
Jacques Chester
31-Jan-2007 06:10
Note that this function overwrites existing files of the same name.

ZipArchive::close> <ZipArchive::addFile
Last updated: Fri, 29 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites