I think anyone who had tried at least once to run a webserver + PHP instance would agree that what's shown in OP's picture could very likely have been a sign of Apache / PHP misconfiguration (or for that matter simply PHP not running).
However indeed not everyone has the minimal degree of experience with webserver + PHP instances to understand that. If you add a wall of possibly bugged PHP code to that you'll understand why people may be scared off by that.
This and the fact that we're flooded with off-topic questions don't help in keeping a straight mind sometimes. And sometimes the stance becomes "when in doubt, close". It's not something we shoud pursue, but it inevitabily happens. And I'm sure I've made the same mistake sometimes.
But yes, that was an error. That question shouldn't have been closed without a basic debugging along the lines of "Is PHP running?".
Since the issue is fixed (OP is happy) and it's not clear what caused it, I won't vote to reopen it.
Just out of curiosity, I've tested OP's code: it works.