php pass by reference code example
Example 1: php pass by reference
<?php
function appendToString(&$string)
{
$string .= 'Cool Im appended';
}
$str = 'I am a start and - ';
appendToString($str);
echo $str; // outputs 'I am a start and - Cool Im appended'
?>
Example 2: javascript pass by reference
function add(a, b, output) {
output.out = a + b;
}
var output = {};
add(5, 3, output);
console.log(output); //output: {out: 8}