Not sure if anyone has any hard data on this so if someone tells you it is one or the other makes ure they give you something to back that up. But I think you'll find that most will recommend the folder so you don't have to change your filename if you change technologies and it is easier for users to type in.
I'd say folder, for stymiee's reasons, and for another very picky one.
If the URL appears in anchor text, the link text for the folder one would be:
www example com keyword
and for the keyword one:
www example com keyword php
The first one has a higher keyword density. But that's being very picky and I doubt it would make any significant difference. If you have an existing structure, don't change it - it wouldn't be worth it.
Which should I use?
The #3 would just forward to 2, but I don't know if it would make a difference.
#2 vs #3 doesn't really matter. I'd stick with either of those... if you change technologies, you'll have to update several references to the files and lose the rankings. Plus, example.com/folder is easier to remember than having a pointless filename.
Most importantly, though, is that you're consistent. If you link to the folder, always link to the folder.