The template tags the_permalink
and the_title
do not return values, they echo them.
Use get_permalink
and get_the_title
instead.
As an aside, the earlier are simply wrappers that echo the return of the latter.
As another aside, yes, the naming is inconsistent.
(And yes, that’s annoying. At least to me.)