I have seen many times that logos and links to a home page of a site use the following:
<?php echo $_SERVER['PHP_SELF']?>
Sadly, its is very dangerous because it might carry additional trailing data. This is specially an issue when doing SEO.
For example:
It will work fine for: /moo/daaa/boo.php
It will possibly redirect to self: /moo/daa/boo.php/mooo/daa.htm
According to some people the behavior is erratic on different configurations.
To prevent all problems I recommend using __FILE__. The following solution which works on PHP 4.0.2 and up:
<?php echo basename(__FILE__) ?>