Last week i had to write a Joomla code in external file. The code contained joomla database queries n other stuff which I don't wanted to convert into core php. I wanted to run the code in external php file by making few changes only. Searched on Google but i found many links of old code & some snippet posted on stackoverflow didn't work. The code which i found was very large containing configuration file
& database details n all unwanted stuff to access Joomla classes.
You can use following code when you want to load Joomla framework outside the Joomla.
Using above snippet you can load the necessary files so that you can use Joomla classes in your PHP script. Code properly worked on Joomla 2.5 version.