Doc #53509 [Opn->Csd]: Incorrect Phar Example; Confusing Results
| From: | kalle@php.net | Date: | Mon, 20 Dec 2010 02:25:04 +0000 |
| Subject: | Doc #53509 [Opn->Csd]: Incorrect Phar Example; Confusing Results | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5705@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53509&edit=1
ID: 53509
Updated by: kalle@php.net
Reported by: royanee at yahoo dot com
Summary: Incorrect Phar Example; Confusing Results
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: PHAR related
Operating System: Linux
PHP Version: 5.3.3
-Assigned To:
+Assigned To: kalle
Block user comment: N
Private report: N
New Comment:
It is excepted that the ArrayAccess returns the path to the file rather
than its contents (as Phar::offsetGet() which is inherited does).
Phar provides a class named PharFileInfo that can be used to fetch the
file contents, but you have to read it line by line (see:
http://dk.php.net/manual/en/pharfileinfo.construct.php),
so using the
filesystem functions would be more simplified.
I corrected the example for what it outputs.
Previous Comments:
------------------------------------------------------------------------
[2010-12-20 03:19:34] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=306484
Log: Fixed bug #53509 (Incorrect Phar Example; Confusing Results)
------------------------------------------------------------------------
[2010-12-09 16:14:36] royanee at yahoo dot com
Description:
------------
---
From manual page: http://www.php.net/phardata.copy#Examples
---
The output of the top half of the example claims to be "hi", but the
output is actually "phar:///path/to/myphar.tar/b"
What is the way with the least overhead to pull a file's content out of
a PharData? I was hoping to be able to access the file content through
the ArrayAccess, but so far only file_get_contents and readfile have
worked. Thanks.
Test script:
---------------
<?php
try {
$phar = new PharData('myphar.tar');
$phar['a'] = 'hi';
$phar->copy('a', 'b');
echo $phar['b']; // outputs "hi"
} catch (Exception $e) {
// handle error
}
Expected result:
----------------
hi
Actual result:
--------------
phar:///path/to/myphar.tar/b
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53509&edit=1