Jump to content

Php Timing


gongpex

Recommended Posts

Hello everyone, In javascript we can use "setTimeout()" to create timing function, but in php taqs I cannot found taqs same as "setTimeout()", I want to create PHP like this case:

for 5 seconds it can display "please wait", but after 5 seconds (time over) it can display "HELLO"
same as "setTimeout()" in javascript, But in PHP, what taq same as "setTimeout ? please tell me thank you
Link to comment
Share on other sites

It's important to keep in mind the purposes of PHP and JavaScript.JavaScript runs on the client. As you use setTimeout(), other things run as well in parallel. User interaction events (clicks, key presses, mouse moves, etc.) are still detected and code is still executed if attached to these events, in turn allowing you to interact with the user without page reloads.PHP runs on the server. Before any interactions with the client start, PHP must give the client everything or at least everything that they need for the interaction. PHP is only triggered when the page is requested and can't be attached to interaction events.The mentioned sleep() function doesn't let you run things in parallel. It simply delays output (and inherently, user interactions) for the specified amount of time. The PHP script doesn't do anything for that time, and the client doesn't get to do anything while they wait.What is it exactly that you're trying to achieve anyway?

Link to comment
Share on other sites

PHP cannot replace JavaScript. You need to make your website work acceptably without it being able to display "HELLO" after waiting five seconds.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...