Doc #63246 [Asn->Csd]: SplFileObject::__construct() example showing code in expected output box.
| From: | salathe@php.net | Date: | Tue, 09 Oct 2012 15:44:39 +0000 |
| Subject: | Doc #63246 [Asn->Csd]: SplFileObject::__construct() example showing code in expected output box. | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-8951@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63246&edit=1
ID: 63246
Updated by: salathe@php.net
Reported by: simon dot champion at connectionservices dot com
Summary: SplFileObject::__construct() example showing code in
expected output box.
-Status: Assigned
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Assigned To: salathe
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2012-10-09 13:02:11] salathe@php.net
That is true, the example could be improved to better avoid confusion.
------------------------------------------------------------------------
[2012-10-09 12:22:58] simon dot champion at connectionservices dot com
Sorry: my point was not that the example is incorrect, but that it's unclear. Sorry if I
didn't express that well.
I believe it could be improved by adding something (for example line numbers) to the output. This
would make it clearer that it is the result of the code being run rather than simply a copy of the
original source code.
This is what I would suggest:
<?php
$file = new SplFileObject(__FILE__);
foreach ($file as $lineNum=>$line) {
echo "Line # " . $lineNum . ": " . $line;
}
?>
------------------------------------------------------------------------
[2012-10-09 12:00:29] salathe@php.net
As the page states, "This example opens the current file and iterates over its
contents line by line."
The whole point of that example is to open the file containing the example code
and echo each line one by one.
------------------------------------------------------------------------
[2012-10-09 10:39:17] simon dot champion at connectionservices dot com
Description:
------------
---
From manual page: http://www.php.net/splfileobject.construct#refsect1-splfileobject.construct-examples
---
Example #1 SplFileObject::__construct() example
In this example, the "expected output" box is currently showing the code, not the output
(ie it is identical to the box above it containing the code).
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63246&edit=1