If you want to concatenate function result into a string you should be returning it, not echoing it. Echo just sends it to output.
Also you are making a typical mistake of confusing two flavor of WP template tags. Convention is the following:
the_*
template tags echo result immediately;get_the_*
template tags return result.
Internally former is usually calling the latter.