Forum Moderators: coopster

Message Too Old, No Replies

executing function at a later time

         

o0katz0o

6:23 am on May 7, 2004 (gmt 0)

10+ Year Member



I'm making a game sort of thing in PHP and I was wondering if there was a way in PHP that I can pause the execution of a function after x seconds. I don't want the whole script to stop working though, so for example

// function 1

(pauses for 10 seconds) {
// function 2
}

// function 3

i want the script to execute like normal, but pause for 10 seconds before executing function 2, so it would execute function 1 and function 3 then 10 seconds later, execute function 2

this is exactly like the fork() statement found in MOO programming

go here to get a clearer definition.
ftp://ftp.research.att.com/dist/eostrom/MOO/html/ProgrammersManual_37.html#SEC37

is there a way to do this in PHP?

jatar_k

7:21 am on May 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld o0katz0o,

what about sleep [ca2.php.net]

o0katz0o

7:51 am on May 7, 2004 (gmt 0)

10+ Year Member



no, that pauses the execution of the whole script

coopster

12:22 pm on May 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Use a combination, pcntl_fork [php.net] and sleep [php.net] in the forked process.