PHP echo function return value vs echo inside function

immereolo

New Member
Typically, I'll write a function like so:\[code\]function alertClass($field,$full=false){ global $formErrors; $html = $full ? ' class="alert"' : ' alert'; if (!empty($formErrors[$field])) return $html;}\[/code\]and then where I want the html to show I'll echo the return value of the function like so:\[code\]echo alertClass('somefield')\[/code\]but today I was thinking why not just put the echo in the function instead of using it's return value?So instead of "return $html" it would be "echo $html"...Is there an advantage to one way or the other?
 
Back
Top