I would like to create a function that both returns and echoes a value. But not the two together. Or return or echo. And I am looking for a beautiful way to do it. Almost all functions / class methods in my project must have this option.
I can pass to a function a bool value that indicates whether to echo or to return a value but it seems not so beautiful to me.
How, you think, it is better to implement this? Maybe a built-in option in PHP?