What about:
if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME'])) { // code.. }
for simple stuff?