Hi all,

I am having a knightmare trying to get some PHP into the output of
a Perl script. PHP. I've heard rumours of Apache 2.0 allowing multiple
filters, which would be perfect when it's out, but not yet obviously.

I've tried calling the CGI PHP from inside Perl in a few ways:

======
#!/usr/bin/perl
$result = `/usr/bin/php -q << EOF
<?php echo "Hello World"; ?>
EOF
`;
print "Content-Type: text/html\n\n";
print "PHP output was $result\n";
exit;
======

I've also tried running this command as a system() call in Perl, and
sending the output of /usr/bin/php to a temporary file, then using
Perl to open and read the contents of that file.

Both methods work if I call the script myself at a shell prompt. In
the case of the file creation, an 11 byte file is duly created.

However, when I call the perl script from a web browser, I lose the
PHP output. The code given above doesn't help narrow it down, but
in the case of the file creating version, I notice back at a shell
prompt that the call to /usr/bin/php has made a 0 byte file... which
obviously explains why I see nothing once Perl copies it to the output.

So, that means there is something about /usr/bin/php that is making it
generate absolutely no output when called via apache and the perl script.

I am guessing that this has to do with the environment variables, as I
can see no other way in which /usr/bin/php would be aware of a difference
in its environment.

So, my question is, does anybody know how to persuade PHP to give me the
output when called in this way... perhaps by forging an environment 
variable from Perl first, or some clever command line switch...

Alternatively, and much preferred, some way of parsing the whole of the
perl output through PHP before returning to the browser. Then I could
just print PHP tags in my Perl output and Apache/mod_php would handle
the rest on the way back...

For reasons that really aren't worth going into, I need to access some
messy PHP functions from Perl, and I can't rewrite the PHP functions in
Perl because I have .php pages that need them, and I can't rewrite the
Perl scripts in PHP either. If I can't find a way of doing this, I will
probably tear all my hair out and then sit down to rewrite a separate
copy of every routine in Perl, and have two copies of all the code in
two different languages... knightmare come true !

Please please help me !!!

James
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to