Which would you say is the 'safest' one to use in terms of accessibility?
Neither?
If you're going to use javascript for a back link (which is perfectly acceptable from an accessibility point of view as you're simply replicating the functionality of the browser Back button), then use javascript to generate the link. That way, no js, no link, no foul.
@t31os: OK - so your version doesn't use js but it will generate an empty link in some situations. Put a link on a page (even an empty link) and people will try to use it. At best, it will confuse some and undermine the confidence of others. At worst, the empty link can cause confusion for screen reader users (who use Link Lists for primary navigation) and create an unwanted hurdle for those who are forced to navigate pages by keyboard or using switch access.
I've not tried this as, for the most part I'm not a big believer in replicating basic browser functionality but how about:
<?php $back =$_SERVER['HTTP_REFERER'];
if((isset($back) && $back !='') echo '<a href="'.$back.'">Go back</a>';?>
Again, no recent browser history, no link.
If you're feeling clever, you could also add in an additional check to see if the referrer was on your domain/site. If the check fails - no link. Which would stop you sending someone back to another site...