You cannot know from PHP code whether the current page is being loaded inside someone's iframe. PHP is run at the server, before anything is sent to the browser.
Only JavaScript, which runs in the browser, can detect if its window is the parent or not and do something about it.