hi!
I dont know any way you can do this from within a function.
But PHP has got several functions, that either echo or only return.
PHP in these cases has got an optional flag, true/false, as argument.
For example:
// this means echo return value
print_r( $a );
// this will not echo, but return the output
$b = print_r( $a, true);
You use an optional, extra argument
This is how you can do this in your function
<?php
function myfunc( $a, $ret=false ){
// do something with $a
if( $ret ){
return $something;
}
else{
echo $something;
return;
}
}