You are here: Re: passthru + auto generated headers « PHP Programming Language « IT news, forums, messages
Re: passthru + auto generated headers

Posted by Daniel Tryba on 10/25/13 11:21

Martin Kofahl <no@spam> wrote:
> I'm slightly confused with the passthru() command. The program I call writes
> html headers itself. However, passthru() makes apache sending some generated
> headers first. There's no fault with spaches in the code etc, I think.
> Here's an simplified example:
>
>
> $ cat /www/example.php
> <?
> passthru("cat /tmp/output");
> ?>

http://nl3.php.net/passthru
"passthru -- Execute an external program and display raw output"

In PHP's context output is http body, http headers can be set with
headers.

Couple of possibilities:
-tell/make the program not to output it's own headers
-call the program directly as a cgi
-suppress php's header generation
-have php filter the output and extract the headers

The last one might be most approriate:
just read the output (popen/fopen) line line by line. Everything till
the first blank line are headers, so output them using header().
Everything after that is the body and could be sent to the client with
echo.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация