Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5776

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Delay execution</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.show-source.html">show_source</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.sys-getloadavg.html">sys_getloadavg</a></div>
 <div class="up"><a href="ref.misc.html">Misc. Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.sleep" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sleep</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">sleep</span> &mdash; <span class="dc-title">Delay execution</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.sleep-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>sleep</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$seconds</code></span>
   )</div>

  <p class="simpara">
   Delays the program execution for the given number of
   <em><code class="parameter">seconds</code></em>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.sleep-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">seconds</code></em></span>
     <dd>

      <p class="para">
       Halt time in seconds.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.sleep-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns zero on success, or <strong><code>FALSE</code></strong> on error.
  </p>
  <p class="para">
   If the call was interrupted by a signal,  <span class="function"><strong>sleep()</strong></span> returns
   a non-zero value. On Windows, this value will always be
   <em>192</em> (the value of the
   <strong><code>WAIT_IO_COMPLETION</code></strong> constant within the Windows API).
   On other platforms, the return value will be the number of seconds left to
   sleep.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.sleep-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   If the specified number of <em><code class="parameter">seconds</code></em> is negative,
   this function will generate a <strong><code>E_WARNING</code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.sleep-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.3.4</td>
       <td>
        Before PHP 5.3.4, on Windows,  <span class="function"><strong>sleep()</strong></span> always
        returns <strong><code>NULL</code></strong> when sleep has occurred, regardless of whether the
        sleep was interrupted or not.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.sleep-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-3784">
    <p><strong>Example #1  <span class="function"><strong>sleep()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;current&nbsp;time<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'h:i:s'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;sleep&nbsp;for&nbsp;10&nbsp;seconds<br /></span><span style="color: #0000BB">sleep</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;wake&nbsp;up&nbsp;!<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'h:i:s'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>
     This example will output (after 10 seconds)
    </p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
05:31:23
05:31:33
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.sleep-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.usleep.html" class="function" rel="rdfs-seeAlso">usleep()</a> - Delay execution in microseconds</span></li>
    <li class="member"> <span class="function"><a href="function.time-nanosleep.html" class="function" rel="rdfs-seeAlso">time_nanosleep()</a> - Delay for a number of seconds and nanoseconds</span></li>
    <li class="member"> <span class="function"><a href="function.time-sleep-until.html" class="function" rel="rdfs-seeAlso">time_sleep_until()</a> - Make the script sleep until the specified time</span></li>
    <li class="member"> <span class="function"><a href="function.set-time-limit.html" class="function" rel="rdfs-seeAlso">set_time_limit()</a> - Limits the maximum execution time</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.show-source.html">show_source</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.sys-getloadavg.html">sys_getloadavg</a></div>
 <div class="up"><a href="ref.misc.html">Misc. Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>