This is a headache, and my solution is to use absolute paths and keep it portable with $MAIN_PATH and $Con_MAINPATH variables.
For example:
$Con_MAINPATH="http://lastleaf.51.net/cgi-bin";
$MAINPATH="/home/myweb/ cgi-bin"
#include "$MAINPATH/php/showphp.php"; //Call other files.
//If showphp.php also calls other files,
//Write "url=$Con_MAINPATH/php/title.gif".
?>
Pay attention to distinguish url and file path, for example:
$fp=fopen("$MAINPATH/files/a.htm","r");
echo "Click here";