<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.pcntl.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.pcntl-exec.php',
    1 => 'pcntl_exec',
    2 => 'Executes specified program in current process space',
  ),
  'up' => 
  array (
    0 => 'ref.pcntl.php',
    1 => 'PCNTL Functions',
  ),
  'prev' => 
  array (
    0 => 'function.pcntl-errno.php',
    1 => 'pcntl_errno',
  ),
  'next' => 
  array (
    0 => 'function.pcntl-fork.php',
    1 => 'pcntl_fork',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pcntl/functions/pcntl-exec.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pcntl-exec" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pcntl_exec</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pcntl_exec</span> &mdash; <span class="dc-title">Executes specified program in current process space</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.pcntl-exec-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">function</span> <span class="methodname"><strong>pcntl_exec</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$args</code><span class="initializer"> = []</span></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$env_vars</code><span class="initializer"> = []</span></span>): <span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></div>

  <p class="para rdfs-comment">
   Executes the program with the given arguments.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pcntl-exec-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">path</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">path</code> must be the path to a binary executable or a
       script with a valid path pointing to an executable in the shebang (
       #!/usr/local/bin/perl for example) as the first line.  See your system&#039;s
       man execve(2) page for additional information.
      </p>
     </dd>
    
    
     <dt><code class="parameter">args</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">args</code> is an array of argument strings passed to the
       program.
      </p>
     </dd>
    
    
     <dt><code class="parameter">env_vars</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">env_vars</code> is an array of strings which are passed as
       environment to the program.  The array is in the format of name =&gt; value,
       the key being the name of the environmental variable and the value being
       the value of that variable.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pcntl-exec-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="simpara">
   Returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure. On success the function does not return, because
   the current process image is replaced by the executed program.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.pcntl-exec-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="simpara">
   As of PHP 8.5.0, a <span class="exceptionname"><a href="class.valueerror.php" class="exceptionname">ValueError</a></span> is thrown if any
   entry of <code class="parameter">args</code> contains a null byte, or if any
   entry or key of <code class="parameter">env_vars</code> contains a null byte.
  </p>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.5.0</td>
      <td>
       A <span class="exceptionname"><a href="class.valueerror.php" class="exceptionname">ValueError</a></span> is now thrown if any entry of
       <code class="parameter">args</code> contains a null byte, or if any entry or
       key of <code class="parameter">env_vars</code> contains a null byte.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.pcntl-exec-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.pcntl-fork.php" class="function" rel="rdfs-seeAlso">pcntl_fork()</a> - Forks the currently running process</span></li>
   <li><span class="function"><a href="function.pcntl-waitpid.php" class="function" rel="rdfs-seeAlso">pcntl_waitpid()</a> - Waits on or returns the status of a forked child</span></li>
   <li><span class="function"><a href="function.exec.php" class="function" rel="rdfs-seeAlso">exec()</a> - Execute an external program</span></li>
   <li><span class="function"><a href="function.proc-open.php" class="function" rel="rdfs-seeAlso">proc_open()</a> - Execute a command and open file pointers for input/output</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>