How can I make my PHP portable to another site?

Very often forms are developed on a test site and then later moved to the live site which may be on a completely different domain, server or hosting service. If the folder paths and URLs have been hard-coded it can be time-consuming and messy to hunt them all down and change them to the new values. Fortunately Joomla! can help us write site independent folders and URLs that will automatically be updated to the settings for the current site.
There are two different groups of Joomla! PHP values that you can use here.
A) There are some Defined terms for Paths (that is folder paths not URLs) like JPATH_SITE, JPATH_ROOT, JPATH_BASE, JPATH_COMPONENT and JPATH_ADMINISTRATOR
Usually JPATH_SITE is the one to use if you are in the front-end.
Note that this doesn't include a final / separator so you need to add that. In Joomla! 1.5 you needed to specify the path separator using DS to handle both Windows and Linux servers. In Joomla! 2.5 I think this is supposed to be automated but I still add it.
So a path might look like JPATH_SITE.DS.'components.DS.'com_chronoforms'.DS.'includes'.DS.'some_file_name'
Here's an extract from the Joomla! Forums with a little more explanation:
JPATH_SITE is meant to represent the root path of the JSite application, just as JPATH_ADMINISTRATOR is mean to represent the root path of the JAdministrator application.
JPATH_BASE is the root path for the current requested application.... so if you are in the administrator application, JPATH_BASE == JPATH_ADMINISTRATOR... if you are in the site application JPATH_BASE == JPATH_SITE... if you are in the installation application JPATH_BASE == JPATH_INSTALLATION.
JPATH_ROOT is the root path for the Joomla install and does not depend upon any application.
B) If you want the URL - for example in PayPal Notify URLs - then use the JURI object which lets you access the current URL. Again there are several different methods. JURI::base(), JURI::root(), JURI::current()
You probably want to use JURI::root() for your URLs in the front-end.
Note JURI::root() does include the final \ separator so you don't need to include this and you don't need to use the DS in URLs so an example would be JURI::root().'index.php?option=com_chronoforms&chronoform=order_card&event=ipn'
There are a lot more JURI methods that you can use to work with URLs if you need to, check the Joomla! docs if you need them.

There is one more piece of generalisation that you might find useful. The current form name is available in $form->form_details->name so you could use JURI::root()."index.php?option=com_chronoforms&chronoform={$form->form_details->name}&event=ipn" to share code across different forms and sites.
This is also useful if you include files, as I do, into Load JS and Custom Code actions. I have a macro set up to do this:
<?php
include (JPATH_SITE.DS.'components'.DS.'com_chronoforms'.DS.'includes'.DS.$form->form_details->name.DS.'load_js.js');
?>