I have made a small function (WordPress), using echo .
/* .. Some code */
switch ($linktype) {
case \"next\":
echo \'
The issue is that the WordPress previous_post_link('%link',''.$prevthumbnail.'')
function actually has its own print command built-in, and it prints after the echo finishes its printing.
If you want to use this command within an echo (or to save to a string) you must use get_previous_posts_link, which instead of printing the value returns it.