note 20939 rejected from language.variables by torben

From: Date: Mon, 22 Apr 2002 20:52:01 +0000
Subject: note 20939 rejected from language.variables by torben
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-29699@lists.php.net to get a copy of this message
Dude, The below is a bad, needlessly confusing example for a reference aimed at beginners. <?php $foo = 'Bob'; // Assign the value 'Bob' to $foo $bar = &$foo; // Reference $foo via $bar. $bar = "My name is $bar"; // Alter $bar... echo $foo; // $foo is altered too. echo $bar; ?> Why do '$bar = "My name is $bar";'? And then do 'echo $foo' *before* you 'echo $bar'? The point you're trying to make is surely expressed better like this: <?php $foo = 'Bob'; // Assign the value 'Bob' to $foo $bar = &$foo; // Reference $foo via $bar. $bar = "Dave"; // Alter $bar... echo $bar; echo $foo; // $foo is altered too. ?> Sure, the previous example is equivalent, but why not make the point as simply as possible? Your documentation should target the 13-year-old shepherd boy in Iraq who's learnt English from MRE wrappers as well as the 29-year-old MIT geek.

« previous php.notes (#29699) next »