How can references be used in PHP functions to modify variables passed as arguments?
To modify variables passed as arguments in PHP functions, you can use references. By passing variables by reference, changes made to the parameter inside the function will affect the original variable outside the function. This can be achieved by using an ampersand (&) before the parameter name in the function definition. Example:
function modifyVariable(&$var) {
$var = $var * 2;
}
$value = 5;
modifyVariable($value);
echo $value; // Output will be 10