#28. PHP Function Argument By Reference

Function Argument By Reference


Run Code:

<?php

function test(&$string){

$string .= " Test 2";

}

$str= "Testing";

test($str);

echo $str;


function first(&$num){
    $num += 5;
}
function second(&$num){
    $num += 10;
}
$no = 10;
first($no);
echo "Original Value is $no <br>";
second($no);
echo "Original Value is $no <br>";

?> 

Comments

Popular posts from this blog

#30. PHP Recursive Function