Php defines the runtime of php code-PHP source code

Source: Internet
Author: User
Ec (2); php defines the php code runtime definition and usage time_sleep_until () function delays code execution until the specified time. The time_sleep_until (timestamp) parameter description is required. The timestamp when the script is awakened. Indicates that the script is paused until the specified timestamp. If the return value is successful, TRUE is returned. If the return value is failed, FALSE is returned. Error/exception if the specified script ec (2); script

Php defines the php code running time
Definition and usage
The time_sleep_until () function delays code execution until the specified time.

Syntax
Time_sleep_until (timestamp)

Parameter description
Timestamp is required. The timestamp when the script is awakened.

Description
Pause the script until the specified timestamp.

Return Value
If the call succeeds, TRUE is returned. If the call fails, FALSE is returned.

Error/exception
If the specified timestamp is in the past, this function generates an E_WARNING.

Tips and comments
Note: All signals will be delivered after the script is awakened.

Note: This function is not implemented on Windows.

Time_sleep_until
(PHP 5> = 5.1.0)

Time_sleep_until-Make the script sleep until the specified time
Set the Script Execution Delay Time

If (! Function_exists ('time _ sleep_until ')){
Function time_sleep_until ($ future ){
If ($ future <time ()){
Trigger_error ("Time in past", E_USER_WARNING );
Return false;
}
Sleep ($ future-time ());
Return true;
}
}
?>

// Implementation for <5.1 or Windows users
If (! Function_exists ('time _ sleep_until ')){
Function time_sleep_until ($ future ){
If ($ future <time ()){
Trigger_error ("Time in past", E_USER_WARNING );
Return false;
}
Usleep ($ future-microtime (1) * 1000000 );
Return true;
}
}
?>

// Returns false and generates a warning
Var_dump (time_sleep_until (time ()-1 ));
// May only work on faster computers, will sleep up to 0.2 seconds
Var_dump (time_sleep_until (time () + 0.2 ));
?>

// + ------------------------------------------------------------------------ +
// | PHP Version 4 |
// + ------------------------------------------------------------------------ +
// | Copyright (c) 1997-2004 The PHP Group |
// + ------------------------------------------------------------------------ +
// | This source file is subject to version 3.0 of the PHP license, |
// | That is bundled with this package in the file LICENSE, and is |
// | Available at through the world-wide-web at |
// | Http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | Obtain it through the world-wide-web, please send a note to |
// License@php.net so we can mail you a copy immediately. |
// + ------------------------------------------------------------------------ +
// | Authors: Arpad Ray |
// + ------------------------------------------------------------------------ +
//
// $ Id: time_sleep_until.php, v 1.2 2005/12/07 21:08:57 aidan Exp $

/**
* Replace time_sleep_until ()
*
* @ Category PHP
* @ Package PHP_Compat
* @ Link http://php.net/time_sleep_until
* @ Author Arpad Ray
* @ Version $ Revision: 1.2 $
* @ Since PHP 5.1.0
* @ Require PHP 4.0.1 (trigger_error)
*/
If (! Function_exists ('time _ sleep_until ')){
Function time_sleep_until ($ timestamp)
{
List ($ usec, $ sec) = explode ('', microtime ());
$ Now = $ sec + $ usec;
If ($ timestamp <= $ now ){
User_error ('specified timestamp is in the past ', E_USER_WARNING );
Return false;
}
$ Diff = $ timestamp-$ now;
Usleep ($ diff * 1000000 );
Return true;
}
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.