Printing within functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux