PHP - function that both returns and echoes a value -


i create function both returns , echoes value. not 2 together. or return or echo. , looking beautiful way it. functions / class methods in project must have option.

i can pass function bool value indicates whether echo or return value seems not beautiful me.

how, think, better implement this? maybe built-in option in php?

passing boolean value way go, print_r same:

mixed print_r ( mixed $expression [, bool $return = false ] )

if capture output of print_r(), use return parameter. when parameter set true, print_r() return information rather print it.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -