It's better to hand code, than rely on an editor that inserts and constructs its own code.

A really good free editor is notepad++. It supports all known languages, colour coding it, and line numbering.

You can insert php code wherever you want within your html file. You just need to wrap the PHP in the <?PHP ?> tags to tell the server where to parse it.

If I have chance later I will knock you up a quick PHP file and attach it for you to look at and play around with.