What is a framebuster in PHP and how is it typically used?

A framebuster in PHP is a piece of code used to prevent a webpage from being displayed within an iframe on another site. This is commonly used to prevent clickjacking attacks where a malicious site tries to trick users into clicking on something on a legitimate site displayed within an iframe. To implement a framebuster in PHP, you can include a script in your webpage that checks if it is the top level window and redirects if it is not.

<?php
// Check if the page is in the top level window
if (top !== self) {
    header("Location: /");
    exit;
}
?>