It's a Mac. I'm using MAMP.
And I just figured, it works fine when apache is ON, the php files are perfectly parsed and I get the required output.
But when apache is OFF, it doesn't work. Whenever I try opening a PHP file, firefox simply pops up a download dialog.