PHP5 has a Pass-by-reference notation: &$bar in line 3 as seen here in the parameter to a function bar(); Basically, this is just a point from the sub routine’s “$bar” back to the caller’s $foo. In this case, a change to the reference variable $bar is reflected in the main variable $foo.
“bar points to/references foo”
$bar => $foo;
1
Output:
foo:foo
bar:foo
bar:bar
foo:bar
Recommended reading: PHP 5 Objects, Patterns, and Practice
GD Star Rating
a WordPress rating system
a WordPress rating system
GD Star Rating
a WordPress rating system
a WordPress rating system
reader
July 30, 2008 at 7:55 am
I’d like to pass by value…
a WordPress rating system
a WordPress rating system
Ian
November 12, 2008 at 7:16 am
Just leave out the ampersand to pass by value, eg.
function bar($bar = NULL)
a WordPress rating system
a WordPress rating system