<?php
// Declare a function that modifies its argument by reference
function addTen(&$num) {
$num += 10;
}
// Initialize a variable
$num = 5;
// Call the function and pass the variable by reference
addTen($num);
// Print the modified value
echo "The value of num after adding 10 is: $num";
?>
The value of num after adding 10 is: 15
addTen
` that takes one parameter `$num
` by reference using the `&
` operator. Inside the function, we add 10
to the value of `$num
`. $num
` is passed by reference, any changes made to it inside the function will also be reflected outside the function.$num
` with the value `5
`. We call the function `addTen
` and pass the variable `$num
` by reference. $num
` using the `echo
` statement. The output shows that the value of `$num
` has been modified to `15
` after adding 10
inside the function.