Only same domain access php file

I have a file that I want only the same domain to be able to access, how can i do this?

Place it above your web root.

Thanks, yes that is an option. Just wondering, is there any way of doing this within the php file itself though?