What is the mechanism of referencing in PHP and how does it work in terms of symbol tables?

When referencing variables in PHP, it is important to understand how PHP's symbol tables work. When a variable is referenced, PHP looks up the variable's value in the symbol table based on its name. If the variable is not found in the current symbol table, PHP will look in the parent symbol table until it finds the variable or reaches the global symbol table.

$var1 = 10;
$var2 = &$var1; // referencing $var1 by using the & symbol
echo $var2; // outputs 10