php : echo"", print(), printf()

Viewed 51627

Is there a better way to output data to html page with PHP?

If I like to make a div with some var in php, I will write something like that

print ('<div>'.$var.'</div>');

or

echo "'<div>'.$var.'</div>'";

What is the proper way to do that?

Or a better way, fill a $tempvar and print it once? like that:

$tempvar = '<div>'.$var.'</div>'
print ($tempvar);

In fact, in real life, the var will be fill with much more!

8 Answers
Related