- add check for the return values ZipArchive::open, some examples

were not updated. Braindead--;


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@218030 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Pierre Joye 2006-08-12 15:54:51 +00:00
parent 1c3c13317a
commit 8adf44cc65
9 changed files with 33 additions and 31 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<refentry id="function.ziparchive-addfile">
<refnamediv>
<refname>ZipArchive::addFile</refname>
@ -59,7 +59,7 @@
<![CDATA[
<?php
$zip = new ZipArchive;
if ($zip->open('test.zip')) {
if ($zip->open('test.zip') === TRUE) {
$zip->addFile('/path/to/index.txt'), 'newname.txt');
$zip->close();
echo 'ok';

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<refentry id="function.ziparchive-addfromstring">
<refnamediv>
<refname>ZipArchive::addFromString</refname>
@ -55,7 +55,7 @@
<?php
$zip = new ZipArchive;
$res = $zip->open('test.zip', ZipArchive::CREATE);
if ($res) {
if ($res === TRUE) {
$zip->addFromString('test.txt', 'file content goes here');
$zip->close();
echo 'ok';
@ -72,7 +72,7 @@ if ($res) {
<![CDATA[
<?php
$zip = new ZipArchive;
if ($zip->open(realpath('test.zip'))) {
if ($zip->open('test.zip') === TRUE) {
$zip->addFromString('dir/test.txt', 'file content goes here');
$zip->close();
echo 'ok';

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<refentry id="function.ziparchive-deleteindex">
<refnamediv>
<refname>ZipArchive::deleteIndex</refname>
@ -44,7 +44,7 @@
<![CDATA[
<?php
$zip = new ZipArchive;
if ($zip->open(realpath('test.zip'))) {
if ($zip->open('test.zip') === TRUE) {
$zip->deleteIndex(2);
$zip->close();
echo 'ok';

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<refentry id="function.ziparchive-deletename">
<refnamediv>
<refname>ZipArchive::deleteName</refname>
@ -44,7 +44,7 @@
<![CDATA[
<?php
$zip = new ZipArchive;
if ($zip->open(realpath('test1.zip'))) {
if ($zip->open('test1.zip') === TRUE) {
$zip->deleteName('testfromfile.php');
$zip->close();
echo 'ok';

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<refentry id="function.ziparchive-extractto">
<refnamediv>
<refname>ZipArchive::extractTo</refname>
@ -61,7 +61,7 @@
<![CDATA[
<?php
$zip = new ZipArchive;
if ($zip->open('test.zip')) {
if ($zip->open('test.zip') === TRUE) {
$zip->extractTo('/my/destination/dir/');
$zip->close();
echo 'ok';

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<refentry id="function.ziparchive-getarchivecomment">
<refnamediv>
<refname>ZipArchive::getArchiveComment</refname>
@ -63,4 +63,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<refentry id="function.ziparchive-getfromindex">
<refnamediv>
<refname>ZipArchive::getFromIndex</refname>
@ -66,7 +66,7 @@
<![CDATA[
<?php
$zip = new ZipArchive;
if ($zip->open(realpath('test.zip'))) {
if ($zip->open('test.zip') === TRUE) {
echo $zip->getFromIndex(2);
$zip->close();
} else {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<refentry id="function.ziparchive-getfromname">
<refnamediv>
<refname>ZipArchive::getFromName</refname>
@ -76,7 +76,7 @@
<![CDATA[
<?php
$zip = new ZipArchive;
if ($zip->open(realpath('test1.zip'))) {
if ($zip->open('test1.zip') === TRUE) {
echo $zip->getFromName('testfromfile.php');
$zip->close();
} else {
@ -92,10 +92,11 @@ if ($zip->open(realpath('test1.zip'))) {
<![CDATA[
<?php
$z = new ZipArchive();
$z->open(dirname(__FILE__) . '/test_im.zip');
$im_string = $z->getFromName("pear_item.gif");
$im = imagecreatefromstring($im_string);
imagepng($im, 'b.png');
if ($z->open(dirname(__FILE__) . '/test_im.zip')) {
$im_string = $z->getFromName("pear_item.gif");
$im = imagecreatefromstring($im_string);
imagepng($im, 'b.png');
}
?>
]]>
</programlisting>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<refentry id="function.ziparchive-getstream">
<refnamediv>
<refname>ZipArchive::getStream</refname>
@ -46,17 +46,18 @@
<?php
$content = '';
$z = new ZipArchive();
$z->open(dirname(__FILE__) . '/test.zip');
$fp = $z->getStream('test');
if(!$fp) exit("failed\n");
if ($z->open('test.zip')) {
$fp = $z->getStream('test');
if(!$fp) exit("failed\n");
while (!feof($fp)) {
$contents .= fread($fp, 2);
while (!feof($fp)) {
$contents .= fread($fp, 2);
}
fclose($fp);
file_put_contents('t',$contents);
echo "done.\n";
}
fclose($fp);
file_put_contents('t',$contents);
echo "done.\n";
?>
]]>
</programlisting>