What are potential challenges when trying to access the URI of a page within a frameset using PHP?

When trying to access the URI of a page within a frameset using PHP, a potential challenge is that PHP may not directly have access to the URI of the parent page due to security restrictions. One way to overcome this challenge is to use JavaScript to pass the URI from the parent page to the child page within the frameset, and then access it using PHP from the child page.

// JavaScript code in the parent page to pass the URI to the child page
<script>
    var parentURI = window.location.href;
    document.getElementById('childFrame').contentWindow.postMessage(parentURI, '*');
</script>

// PHP code in the child page to receive the URI passed from the parent page
<?php
    if(isset($_POST['parentURI'])){
        $parentURI = $_POST['parentURI'];
        echo "Parent URI: ".$parentURI;
    }
?>