Passing arguments by reference in php program

Pass arguments by reference in php program. Arguments are typically passed by value, which means that the function uses a copy of the value and that the variable passed into the function cannot be changed. Changes to the argument change the variable that was passed in when a function argument is passed by reference. The & operator is used to convert a function argument into a reference.

<!DOCTYPE html>
<html>
<body>
<?php
function add_three(&$value)
{
$value += 3;
}
$num = 2;
add_five($num);
echo $num;
?>
</body>
</html>

 

Output:

3