downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.passthru.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.exec.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.passthru.php',
   
1 => 'passthru',
  ),
 
'up' =>
  array (
   
0 => 'ref.exec.php',
   
1 => 'Program execution Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.exec.php',
   
1 => 'exec',
  ),
 
'next' =>
  array (
   
0 => 'function.proc-close.php',
   
1 => 'proc_close',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.passthru" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">passthru</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">passthru</span> &mdash; <span class="dc-title">Execute an external program and display raw output</span></p>

 </div>

 <a name="function.passthru.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span> <span class="methodname"><b>passthru</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$command</tt></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter reference">&amp;$return_var</tt></span>
  ] )</div>

  <p class="para rdfs-comment">
   The <b>passthru()</b> function is similar to the
   <a href="function.exec.php" class="function">exec()</a> function in that it executes a
   <i><tt class="parameter">command</tt></i>
. This function
   should be used in place of <a href="function.exec.php" class="function">exec()</a> or
   <a href="function.system.php" class="function">system()</a> when the output from the Unix command
   is binary data which needs to be passed directly back to the
   browser.  A common use for this is to execute something like the
   pbmplus utilities that can output an image stream directly.  By
   setting the Content-type to <i>image/gif</i> and
   then calling a pbmplus program to output a gif, you can create
   PHP scripts that output images directly.
  </p>
 </div>


 <a name="function.passthru.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">command</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The command that will be executed.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">return_var</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       If the <i><tt class="parameter">return_var</tt></i>
 argument is present, the
       return status of the Unix command will be placed here.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.passthru.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   No value is returned.
  </p>
 </div>


 <a name="function.passthru.notes"></a><div class="refsect1 notes">
  <h3 class="title">Notes</h3>
  <div class="warning"><b class="warning">Warning</b><p class="para">When allowing user-supplied data to be
passed to this function, use
<a href="function.escapeshellarg.php" class="function">escapeshellarg()</a> or <a href="function.escapeshellcmd.php" class="function">escapeshellcmd()</a>
to ensure that users cannot trick the system into executing arbitrary
commands.</p></div>
  <blockquote><p><b class="note">Note</b>: If a program is started with this function,
in order for it to continue running in the background, the output of the
program must be redirected to a file or another output stream. Failing to do so
will cause PHP to hang until the execution of the program ends.<br /></p></blockquote>
  <blockquote><p><b class="note">Note</b>: <span class="simpara">When
<a href="features.safe-mode.php" class="link">safe mode</a> is enabled, you can only
execute files within the <a href="ini.sect.safe-mode.php#ini.safe-mode-exec-dir" class="link">safe_mode_exec_dir</a>.
For practical reasons, it is currently not allowed to have <i>..</i>
components in the path to the executable.</span></p></blockquote>
  <div class="warning"><b class="warning">Warning</b><p class="simpara">With <a href="features.safe-mode.php" class="link">safe mode</a> enabled,
the command string is escaped with <a href="function.escapeshellcmd.php" class="function">escapeshellcmd()</a>. Thus,
<i>echo y | echo x</i> becomes <i>echo y \| echo x</i>.</p></div>
 </div>


 <a name="function.passthru.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.exec.php" class="function" rel="rdfs-seeAlso">exec()</a> - Execute an external program</li>
    <li class="member"><a href="function.system.php" class="function" rel="rdfs-seeAlso">system()</a> - Execute an external program and display the output</li>
    <li class="member"><a href="function.popen.php" class="function" rel="rdfs-seeAlso">popen()</a> - Opens process file pointer</li>
    <li class="member"><a href="function.escapeshellcmd.php" class="function" rel="rdfs-seeAlso">escapeshellcmd()</a> - Escape shell metacharacters</li>
    <li class="member"><a href="language.operators.execution.php" class="link">backtick operator</a></li>
   </ul><p>
  </p>
 </div>

</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites