Code as Fast as You Can Think
"I have only proved my code correct, not tested it" - Donald Knuth
Search This Blog
Friday, August 14, 2009
PHP, Swap And Pass by Reference
// "&" -- pass by reference
function swap(&$a, &$b)
{
$temp = $a;
$a = $b;
$b = $temp;
}
$apple = "apple";
$orange = "orange";
swap($apple, $orange);
print "apple became: $apple\n";
print "orange became: $orange\n";
?>
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
About Me
Unknown
View my complete profile
No comments:
Post a Comment