I take it you want to put some php code in a string and
print that string lateron, but instead of printing the code you want to print what the code would output if it was executed?
try eval().
Note: eval can be _very_dangerous to your scripts health. Recommend you read and understand the manual page about eval().