How to execute certain part of code (eg sftp download) in php in certain time interval? If time exceeds, exception is to be handled -


i want put time interval sftp connection in php. if time exceeds 60 seconds connect it, should disrupted , exception handled. don't know how it.

i tried do:

set_time_limit(60) 

but, not work.

i want put time limit in function:

private function __connectsftp()     {         $this->sftp = new net_sftp($this->host, 22);           if (!$this->sftp->login($this->user, $this->password))         {             return $this->_requesterrormessage('could not connect server');          } else         {              return $this->__downloadfile();         }       } 

i tried do:

$totime = time()+60;  while(time() != $totime){ //connection code } 

but, sadly doesn't work @ all.

i grateful if suggest me can do.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -