Are there any reliable methods in PHP to determine if a URL was entered directly into the browser or accessed through a webpage?

One way to determine if a URL was entered directly into the browser or accessed through a webpage is by checking the HTTP referer header. When a user clicks on a link on a webpage, the referer header will contain the URL of the webpage that the user came from. If the referer header is empty, it is likely that the URL was entered directly into the browser.

if(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])){
    // URL was accessed through a webpage
    echo "URL was accessed through a webpage";
} else {
    // URL was entered directly into the browser
    echo "URL was entered directly into the browser";
}