Some functions I have used return a string on echo, something like this.
echo my_function();
This prints "hello
" on the screen.
print_r( my_function() );
This prints an array or an object on the screen. The function is the same in both cases, even the possible in parameters.
How is this done?
The possible function
function my_function() {
// If this function is used by echo return the string
// If this function is used by print_r return an array
$string = 'Hello';
$array = array('some', 'data');
// return $string or $array depending on
}
Real life example
This function return an image on echo and an object on print_r: http://getkirby.com/docs/cheatsheet/helpers/thumb