Properly bootstrap drupal for standalone PHP file?
By far the easiest way to manage the bootstrap is to use drush php-script, alias scr.

file.php:

&lt;?php
echo l('Link', 'path');


Cli:

drush @alias scr file.php


Output:

&lt;a href="/path"&gt;Link&lt;/a&gt;


This way you need to deal with nothing with regard to the bootstrap, drush will solve it entirely for you, and gives you the ability to use it easily across sites thanks to aliases. (Might even work on remote sites, though I haven't tried that)