According to the most programming languages scope rules, I can access variables that are defined outside of functions inside them, but why doesn\'t this code work?
You can also simplify
echo "[" . $data . "]"
to
echo "[$data]"