Home > Daily Programming > PHP Knowledge > PHP implements delayed execution program

PHP implements delayed execution program

藏色散人
Release: 2019-06-14 18:06:15
Original
10354 people have browsed it

PHP delays the execution of the program, we can implement it directly through the sleep function in PHP. The sleep function means delayed execution.

PHP implements delayed execution program

Below we will introduce simple code examples to introduce how to delay the execution of programs in PHP.

The code example is as follows:

<?php

// 当前时间
echo date("Y-m-d H:i:s");

// 延迟5秒钟
sleep(5);

echo date("Y-m-d H:i:s");
Copy after login

The output delay result is as shown in the figure below:

PHP implements delayed execution program

sleep means delay.

sleep ( int $seconds ) : int
Copy after login

The program delays execution for the specified seconds seconds. The parameter seconds indicates the number of seconds to pause.

Return value, 0 is returned on success, FALSE is returned on error.

If the function call is terminated by a signal, sleep() will return a non-zero value. On Windows, the value is always 192 (i.e. the value of the Windows API constant WAIT_IO_COMPLETION). On other platforms, the return value is the number of seconds remaining without sleep.

Error/Exception: If the specified seconds is a negative number, this function will generate an E_WARNING level error.

This article is an introduction to the method of implementing delayed execution of programs in PHP. It is simple and easy to understand. I hope it will be helpful to friends in need!

The above is the detailed content of PHP implements delayed execution program. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template