What are the best practices for passing variables by reference in PHP functions?

When passing variables by reference in PHP functions, it is important to use the '&' symbol before the variable name in both the function definition and the function call. This allows the function to directly modify the original variable rather than working with a copy. By passing variables by reference, you can avoid unnecessary memory usage and improve the efficiency of your code.

// Passing a variable by reference in a PHP function

function increment(&$num) {
    $num++;
}

$number = 5;
increment($number);
echo $number; // Output: 6