You missing the point of such interviews. If you're asked to write code on paper you're not expected to produce code that would compile. At least not if you're interviewed by meonion2k wrote:Any company that asks you to write code without having references, even if it's just in an interview, is utterly moronic and not the sort of place I'd want to work at.
The last time I interviewed a candidate, he didn't write a single line of code. In fact he knew very little PHP (he was a Perl developer), but still he was able to explain clearly and concisely how the problem is solved. He asked right questions. He didn't ask wrong questions. Needless to say he passed with flying colors.