0

Is there any equivalent to javascript setTimeout method in php ?

what I know that php is not multithreading but I could be wrong.

zizoujab
  • 7,603
  • 8
  • 41
  • 72

4 Answers4

3

No, there isn't. Mainly because PHP is server-sided so it wouldn't make much sense to have timed events. There is, though, the sleep function which halts the execution for a given time.

federico-t
  • 12,014
  • 19
  • 67
  • 111
1

You can do multi-threading in PHP with pthreads

From PHP manual:

pthreads  is an Object Orientated API that allows user-land multi-threading in PHP.
It includes all the tools you need to create multi-threaded applications targeted at the Web or the Console.
PHP applications can create, read, write, execute and synchronize with Threads, Workers and Stackables.

References

1) http://www.reddit.com/r/PHP/comments/1jo517/multithreading_in_php_with_pthreads/

2) https://github.com/krakjoe/pthreads

Rajesh
  • 3,743
  • 1
  • 24
  • 31
0

PHP has threads so you can fork like you would in other multithreaded languages.

You can always make your own event-loop of course ;)

Halcyon
  • 57,230
  • 10
  • 89
  • 128
0

There is no way that you can get a JS equivalent. Has nothing to do with that. Are different technologies.

I dont know what are trying to do. But you can set the max_execution_time on for php.ini file or override that value at script level.

take a look at

http://php.net/manual/en/function.set-time-limit.php

slash28cu
  • 1,614
  • 11
  • 23