Useful example of passing by reference
The following is a function from the PmWiki Engine » (pmwiki.php).
{
if (!isset($v))
{
$v = $x;
}
}
This checks to see if $v is in use and if not it sets $v to the value of $x.
Passing by reference allows you to work on a variable while modifying it at the same time.
It reminds me of mogrify and convert from the ImageMagick libraries. With convert, you have to specify an input file and a different output file, whereas mogrify takes a file as input and modifys it directly leaving you with the same file, but modified.
[Click to add or edit comments])
Please prepend comments below including a date