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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daniel at mameso dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC