Delay execution of the current script for 5 seconds in PHP

Description

The following code shows how to delay execution of the current script for 5 seconds.

Example


  //from   w w w  .  jav a 2 s .  c om
<?php
    echo date('h:i:s') . "<br>";
    
    //sleep for 5 seconds
    sleep(5);
    
    //start again
    echo date('h:i:s');
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone