I was studying for my finals and I came across this question:
write the output after running this code.
<?php function swap($x, $y) { $x = $x + 1; $y = $y + 2; return $x * $y; } $a = 3; $b = swap($a, $a); print "$a, $b"; $b = swap(&$a, &$a); print "$a, $b"; ?> I understand exactly what this code does, however after I ran it I got a completely different answer to what I answered with and I really don't understand the output. The output I got was 3, 206, 36.
Could someone explain the output to me?
$b = swap(&$a, &$a);. If you want to pass references, set that up in the function signature.function swap(&$x, &$y){. Docs: php.net/manual/en/language.references.pass.php