View Single Post
  #20 (permalink)  
Old 12-18-2007, 06:25 AM
Sabari Sabari is offline
D-Web Genius
 
Join Date: Jul 2007
Posts: 1,008
Sabari is on a distinguished road
Default Re: PHP Tips and Tricks

Returning References

Passing arguments to a function by reference
<?php
function inc(& $b) {
$b++;
}
$a = 1;
inc($a);
echo $a;
?>
Output:
2
A function may return a reference to data as opposed to a copy


<?php
function & get_data() {
$data = "Hello World";
return $data;
}
$foo = & get_data();
?>
__________________
Thanks & Regards
Sabari...
Reply With Quote