Can PHP detect if a frame was not called from another frame but was refreshed instead?

When a frame is refreshed instead of being called from another frame, PHP alone cannot detect this directly as it operates on the server-side. However, you can use JavaScript to detect if a page is being refreshed and then pass this information to PHP using AJAX.

<?php
if(isset($_POST['refreshed'])) {
    // Page was refreshed
    // Handle the logic here
}

?>

<script>
    if (performance.navigation.type === 1) {
        // Page was refreshed
        // Send the information to PHP using AJAX
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                // Handle the response from the server
            }
        };
        xhttp.open("POST", "your_php_file.php", true);
        xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xhttp.send("refreshed=true");
    }
</script>