#50872 [Opn]: inaccurate example in pass-by-reference docs

From: Date: Thu, 28 Jan 2010 21:00:21 +0000
Subject: #50872 [Opn]: inaccurate example in pass-by-reference docs
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3798@lists.php.net to get a copy of this message
ID: 50872 User updated by: neilyalowitz at gmail dot com Reported By: neilyalowitz at gmail dot com Status: Open Bug Type: Documentation problem PHP Version: Irrelevant New Comment: Ok, now I understand. I would recommend just pasting function foo() as defined above in the example given further down the page. Then the code block could be run as-is, readers could observe the error themselves, and there is no ambiguity: <?php function foo(&$var) { $var++; } function bar() // Note the missing & { $a = 5; return $a; } foo(bar()); // Produces fatal error since PHP 5.0.5 foo($a = 5); // Expression, not variable foo(5); // Produces fatal error ?> Previous Comments: ------------------------------------------------------------------------ [2010-01-28 12:56:10] salathe@php.net Please see the function foo() as defined at the top of the page. At least two people have been confused by that example so it will probably make sense to tidy the page up a bit. ------------------------------------------------------------------------ [2010-01-28 10:21:16] neilyalowitz at gmail dot com URL to page I'm referring to: http://www.php.net/manual/en/language.references.pass.php ------------------------------------------------------------------------ [2010-01-28 10:19:48] neilyalowitz at gmail dot com Description: ------------ There must be a mistake in the documentation regarding the "Produces fatal error" documented case. Docs need to be fixed, it doesn't produce a fatal error, the code block runs fine. Reproduce code: --------------- --- From manual page: language.references.pass --- <?php function bar() // Note the missing & { $a = 5; return $a; } //begin-- I added this so the block will run function foo($a) { print $a; } //end foo(bar()); // Produces fatal error since PHP 5.0.5 //no, it doesn't ?> Expected result: ---------------- Docs say it should produce a fatal error. Actual result: -------------- Code block runs fine. No error. Mistake in the docs. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50872&edit=1

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