Doc #63246 [Nab]: SplFileObject::__construct() example showing code in expected output box.

From: Date: Tue, 09 Oct 2012 12:22:58 +0000
Subject: Doc #63246 [Nab]: SplFileObject::__construct() example showing code in expected output box.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8946@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 User updated by: simon dot champion at connectionservices dot com Reported by: simon dot champion at connectionservices dot com Summary: SplFileObject::__construct() example showing code in expected output box. Status: Not a bug Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant Block user comment: N Private report: N New Comment: 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; } ?> Previous Comments: ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#8946) next »