What are references in PHP and how do they work?
References in PHP allow you to create a variable that refers to the same value as another variable. This means that changes made to one variable will affect the other. To create a reference in PHP, you use the ampersand (&) symbol before the variable name. References are useful when you need to pass variables by reference to functions or when you want to avoid making unnecessary copies of large variables.
$original_variable = 10;
$reference_variable = &$original_variable;
echo $original_variable; // Output: 10
echo $reference_variable; // Output: 10
$reference_variable = 20;
echo $original_variable; // Output: 20
echo $reference_variable; // Output: 20