[Solved] What is the equivalent history.go(0) in php? [closed]

Introduction

The history.go(0) command in JavaScript is used to reload the current page. It is a useful command for refreshing the page without having to manually reload it. However, if you are looking for the equivalent command in PHP, there is no direct equivalent. This article will discuss some of the alternatives to history.go(0) in PHP.

Solution

The equivalent of history.go(0) in PHP is to use the header() function to redirect the user back to the same page they were on. For example:

header(“Location: “.$_SERVER[‘REQUEST_URI’]);


Yes, its possible. Use submit buttons to send the form, and use HTTP_REFERER from global $_SERVER array to go back. This is the only way I know without javascript.

But I suggest you to make a javascript check at the page load and tell the user to turn on javascript.

<?php
$back = "https://stackoverflow.com/";
if (!empty($_SERVER["HTTP_REFERER"])) {
    $back = $_SERVER["HTTP_REFERER"];
}
?>
<ul class="dropdown-menu">
    <li><a href="https://stackoverflow.com/questions/38568996/<?php echo $back; ?>">Português</a></li>
    <li><input type="submit" value="Espanhol"></li>
    <li><input type="submit" value="English"></a></li>
</ul>

0

solved What is the equivalent history.go(0) in php? [closed]