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

search for in the

ZipArchive::close> <ZipArchive::addFile
[edit] Last updated: Fri, 24 Jun 2011

view this page in

ZipArchive::addFromString

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)

ZipArchive::addFromStringاضافه کردن فایل به آرشیو ZIP با استفاده از محتوای آن

Description

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

اضافه کردن فایل به آرشیو ZIP با استفاده از محتوای آن.

Parameters

localname

نام ورودی برای ساخته شدن.

contents

محتوا برای ساخت ورودی. در حالت باینری امن استفاده می‌شود.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 اضافه کردن ورودی به آرشیو

<?php
$zip 
= new ZipArchive;
$res $zip->open('test.zip'ZipArchive::CREATE);
if (
$res === TRUE) {
    
$zip->addFromString('test.txt''file content goes here');
    
$zip->close();
    echo 
'ok';
} else {
    echo 
'failed';
}
?>

Example #2 اضافه کردن فایل به دایرکتوری داخل آرشیو

<?php
$zip 
= new ZipArchive;
if (
$zip->open('test.zip') === TRUE) {
    
$zip->addFromString('dir/test.txt''file content goes here');
    
$zip->close();
    echo 
'ok';
} else {
    echo 
'failed';
}
?>


add a note add a note User Contributed Notes ZipArchive::addFromString - [0 notes]
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites