Converting php templates to php