質問

I want to create an application in PHP.

concept is very simple, I want to just auto load every page randomly at a regular intervals. For example, if I entered to facebook.com, it would be auto load randomly profile.php, notifications.php, messages.php etc... I am not sure about its practicality. So my question may be stupid, but I need help. I only know meta refresh which is only for refreshing the page.

<meta http-equiv="refresh" content="5; url=http://example.com/">

But I think, using the loop , My concept will work. But I have no idea how loop will work with meta tag.

役に立ちましたか?

解決 3

I finally got the soloution,

<script>
  var interval = 5; // in seconds
  var pages = [
    'http://website.com/link1.php',
    'http://website.com/link2.php',
    'http://website.com/link3.php'
  ];
  var current_page_index = 0;

  setInterval(function() {
    loadintoIframe('myframe', pages[current_page_index]);
    current_page_index = (current_page_index + 1) % pages.length;
  }, interval * 1000); // second setInterval param is milliseconds
</script>

他のヒント

Looking strange requirement, anyhow, you can use

sleep(5)

function after your page get loads in a recursive way.. you should read this..

The below code will redirect you to the appropriate page. You could check the time stamp, and if it is so much different than the initial page load timestamp, execute the header commmand. You really would be better off using meta in this case.

Header('Location: http://www.google.com');

TrY:

while(1=1){
    sleep(5);

    //Use one of the following methods to refresh.
    echo "<meta http-equiv=\"refresh\" content=\"5; url=/profile.php?pid=".$profile_id."\">";
    Header('Location: /profile.php?pid='.$profile_id);
    echo "<script>javascript:window.href.replace('/profile.php?pid=".$profile_id."');";
}

also review: Server Sent Events

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top