PHP in a Perl Script

G

Gary

I am calling a perl script that writes a WEB page - Plain and simple except
that the perl script also writes out some PHP processing. All works fine
when I just create an html file of the program but when I use perl to write
it the php tags are ignored ?

I have the apache Xbithack on so php is parsed for all html files and the
perl script says it is an html file as below.

This code is called from a WEB page

#!/usr/local/bin/perl
print <<END;
Content-type: text/html

<?php
SCRIPT etc etc
?>
END

PHP tags are just printed on the screen.

Any pointers.
Gary
 
G

Gunnar Hjalmarsson

Gary said:
I am calling a perl script that writes a WEB page - Plain and
simple except that the perl script also writes out some PHP
processing. All works fine when I just create an html file of the
program but when I use perl to write it the php tags are ignored ?

Doesn't PHP require the file extension .php?

Btw, what has your question to do with the Perl programming language?
 
J

John Bokma

I am calling a perl script that writes a WEB page - Plain and simple
except that the perl script also writes out some PHP processing. All
works fine when I just create an html file of the program but when I
use perl to write it the php tags are ignored ?

I have the apache Xbithack on so php is parsed for all html files and
the perl script says it is an html file as below.

This code is called from a WEB page

#!/usr/local/bin/perl
print <<END;
Content-type: text/html

<?php
SCRIPT etc etc
?>
END

PHP tags are just printed on the screen.

Just a wild guess, I think this by passes the webserver. The webserver
does the execution of PHP and it is being asked to execute (Perl) CGI
now.

If that's the actual script you are using, why? What can you do in PHP
you can't in Perl (ok, I am kidding :-D)

Post real code, and ask real questions.
 
R

Richard Gration

I am calling a perl script that writes a WEB page - Plain and simple
except that the perl script also writes out some PHP processing. All
works fine when I just create an html file of the program but when I use
perl to write it the php tags are ignored ?
I have the apache Xbithack on so php is parsed for all html files and
the perl script says it is an html file as below. This code is called
from a WEB page
#!/usr/local/bin/perl
print <<END;
Content-type: text/html
<?php
SCRIPT etc etc
?>
END
PHP tags are just printed on the screen. Any pointers.
Gary

I assume this is on Apache ...

If it's Apache 1.x then the output of your script is parsed for the
presence of a couple of specific headers, which are added if they aren't
there (this is part of the CGI spec) and then sent on it's way to the
browser. It is not possible in Apache 1.x to have this output handed off
to another module for processing (here the request has been served by the
cgi-script handler - you cannot then chain to the php-script handler, not
in Apache 1.x).

However, in Apache 2.x it *is* possible. Not sure how you go about it in
httpd.conf 'cos I don't use it (<aside>Is mod_perl 2.x finished
yet?</aside>), but this is one limitation which was addressed
specifically when designing Apache 2.x, you can now chain content
handlers so that you can have the output of scripts parsed for SSI, have
perl scripts generate php, have SSI generate php which generates perl
(maybe ;-) and other full-on wackiness.

HTH
Rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top