Nagasea,
You should look at $_SERVER['PHP_SELF'], which will evaluate to the current script's relative URL.
This is handy for forms that submit to themselves, for instance:
<form method="get" action="<?php echo $_SERVER['PHP_SELF'];?>">
If you are concerned about inlined images, you might want to consider making your links document- or site-relative.
For example:
file1.html:
<img src="images/foo.jpg">
file2.html:
<img src="/images/foo.jpg">
In the first case, file1 will look for a subdirectory of it's directory called "images" and try to find foo.jpg. This will work if you are moving file1.html and it's subdirectory(s) with it.
In the second case, file2.html will always look at the same directory: namely, "images" which is a subdirectory of document root. This is helpful if you are moving the php or html files around but the images and other resources are going to stay put.
Also, you might look into including a single config file, say config.php:
config.php:
$config_path['images'] = "/foo/images/";
$config_path['icons'] = "/bar/icons/";
and then reference your images/icons like:
<img src="<?=$config_path['images']?>baz.jpg">
Hope that helps.