When you use a single quote:
echo '$foo';
--- PHP thinks you want exactly that to be printed to output.
In order for the variable to be interpolated, use a double quote:
echo "$foo";
This can also work:
echo $foo;
- but the single quote means "literally print whatever is in between these marks".