thats weird. basename() should not strip underscores. its never done that for me.
i dont know why your using dirname() though if you want the filename.......
you could also try pathinfo()
if that doesnt work,
maybe try
echo end(explode('/', __FILE__));
not sure what you meant by the last part of you post, but FILE should give you the filename of the file where you call it from. it should NOT change whether your including a file or not. if your looking for the name of the script which was executed FIRST, use $_SERVER['PHP_SELF']