Drupal bootstrap running from command line
You could also try Drush. Once you've installed it, you can cd into your drupal root then run drush scr test.php. In that file, all Drupal functions will be available.