You think this:
text = '<a href="%s" title="%s">%s</a>'%(mylocation,mytitle,mytext)
is clearer than this:
$text="<a href='$mylocation' title='$mytitle'>$mytext</a>";
???
OK. To each his own.
Try:
$text =sprintf("<a href='%s' title='%s'>%s</a>",$mylocation,$mytitle,$mytext);