php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63461 Error in example code #2
Submitted: 2012-11-08 00:15 UTC Modified: 2012-11-08 02:21 UTC
From: daniel at mameso dot com Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.4.8 OS: osx
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
19 + 32 = ?
Subscribe to this entry?

 
 [2012-11-08 00:15 UTC] daniel at mameso dot com
Description:
------------
---
From manual page: http://www.php.net/function.ziparchive-getstream
---


hi, error in the Example #2 at http://de2.php.net/manual/de/function.ziparchive-
getstream.php



is (wrong):

<?php
$fp = fopen('zip://' . dirname(__FILE__) . '/test.zip#test', 'r');
if (!$fp) {
    exit("Datei kann nicht geƶffnet werden\n");
}
while (!feof($fp)) {
    $contents .= fread($fp, 2);
    echo "$contents\n";
}
fclose($fp);
echo "Erledigt.\n";
?>



problem part is:

while (!feof($fp)) {
    $contents .= fread($fp, 2);
    echo "$contents\n";
}



it adds filecontent to $content and output it so:

aa
aabb
aabbcc
aabbccdd


right is:

while (!feof($fp)) {
    $contents .= fread($fp, 2);
}
echo "$contents\n";


OR

while (!feof($fp)) {
    $contents = fread($fp, 2);
    echo "$contents";
}


best regards,
daniel

Test script:
---------------
see description


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-08 02:21 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328279
Log: Update example 2 of ZipArchive::getStream().

Fixes doc bug #63461 (Error in example code #2).
 [2012-11-08 02:21 UTC] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2012-11-08 02:21 UTC] aharvey@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: aharvey
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 27 02:03:36 2021 UTC