<HTML ><HEAD ><TITLE >passthru</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Program Execution functions" HREF="ref.exec.html"><LINK REL="PREVIOUS" TITLE="exec" HREF="function.exec.html"><LINK REL="NEXT" TITLE="proc_close" HREF="function.proc-close.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.exec.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.proc-close.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.passthru" ></A >passthru</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN78804" ></A ><P > (PHP 3, PHP 4 )</P >passthru -- Execute an external program and display raw output </DIV ><DIV CLASS="refsect1" ><A NAME="AEN78807" ></A ><H2 >Description</H2 >void <B CLASS="methodname" >passthru</B > ( string command [, int return_var])<BR ></BR ><P > The <B CLASS="function" >passthru()</B > function is similar to the <A HREF="function.exec.html" ><B CLASS="function" >exec()</B ></A > function in that it executes a <TT CLASS="parameter" ><I >command</I ></TT >. If the <TT CLASS="parameter" ><I >return_var</I ></TT > argument is present, the return status of the Unix command will be placed here. This function should be used in place of <A HREF="function.exec.html" ><B CLASS="function" >exec()</B ></A > or <A HREF="function.system.html" ><B CLASS="function" >system()</B ></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 <SPAN CLASS="emphasis" ><I CLASS="emphasis" >image/gif</I ></SPAN > and then calling a pbmplus program to output a gif, you can create PHP scripts that output images directly. </P ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Warning</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > If you are going to allow data coming from user input to be passed to this function, then you should be using <A HREF="function.escapeshellarg.html" ><B CLASS="function" >escapeshellarg()</B ></A > or <A HREF="function.escapeshellcmd.html" ><B CLASS="function" >escapeshellcmd()</B ></A > to make sure that users cannot trick the system into executing arbitrary commands. </P ></TD ></TR ></TABLE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > If you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends. </P ></BLOCKQUOTE ></DIV ><P > See also <A HREF="function.exec.html" ><B CLASS="function" >exec()</B ></A >, <A HREF="function.system.html" ><B CLASS="function" >system()</B ></A >, <A HREF="function.popen.html" ><B CLASS="function" >popen()</B ></A >, <A HREF="function.escapeshellcmd.html" ><B CLASS="function" >escapeshellcmd()</B ></A >, and the <A HREF="language.operators.execution.html" >backtick operator</A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.exec.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.proc-close.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >exec</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.exec.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >proc_close</TD ></TR ></TABLE ></DIV ></BODY ></HTML >