I'm creating my own templatesystem because I only need a few little operations to be supported. One of them is loading widgets with dynamic data generated from a database in my template.
Is there a way to parse PHP code, don't display the result but store it in a variable and then use the generated source from that variable somewhere else?
Right now I'm using ob_get_contents()
but whenever I use an echo command it gets overruled and the content displays as the very first thing on my site. This is a behaviour I want to work arround somehow.
Is that possible? Or am i misusing the ob_get_contents
completely?
Everybody thanks for their replies. But i found a silly 'bug' in my code. In my templateparser I'm counting the regions in a template and loop through them, using $i. Then in a widget I had to iterate through a dataset (navigation structure) too, and used $i again. This was creating my problem. I simply had to rename $i to solve my problem.