Joe
Joe

Reputation:

How to execute php file into variable?

Does it possible to execute php file and store its output into some variable?

For example i have one global template, then i need to process subtemplates, and afterall i need to insert that subtemplate output into global template block.

How can i do it ?

Upvotes: 2

Views: 581

Answers (1)

Gumbo
Gumbo

Reputation: 655815

You can use the output control functions, buffer the output with ob_start and retrieve it with ob_get_contents:

ob_start();
func();
$output = ob_get_contents();
ob_end_clean();

Upvotes: 6

Related Questions