Printing within functions
| From: | Philip Thompson | Date: | Mon, 12 Nov 2007 23:55:29 +0000 |
| Subject: | Printing within functions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-264403@lists.php.net to get a copy of this message | ||
Hi. I thought of this when I read the emails about using functions or
includes...
What are your thoughts about *printing* things from within functions? For
example:
<?php
function printSomething () {
echo "Something about nothing. ";
echo "Another something.";
}
function something () {
$text = "Something about nothing. ";
$text .= "Another something.";
return $text;
}
?>
<html>
...
<p><?php printSomething (); ?></p>
<p><?php echo something (); ?></p>
...
</html>
Obviously, these are over-simplified functions, but you get the point.
Nonetheless, do you tend to print things within functions or pass the
results back and then print them? I understand it may depend on the current
context, but which way do you lean and is one way or the other considered
*better practice*?
Thanks,
~Philip