PHP in a Perl Script

Discussion in 'Perl Misc' started by Gary, Aug 25, 2004.

  1. Gary

    Gary Guest

    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
     
    Gary, Aug 25, 2004
    #1
    1. Advertising

  2. Gary wrote:
    > 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?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Aug 25, 2004
    #2
    1. Advertising

  3. Gary

    John Bokma Guest

    "Gary" <> wrote in
    news:MATWc.141004$Oi.85750@fed1read04:

    > 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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Aug 25, 2004
    #3
  4. In article <MATWc.141004$Oi.85750@fed1read04>, "Gary"
    <> wrote:


    > 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
     
    Richard Gration, Aug 25, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wet Basement
    Replies:
    1
    Views:
    2,543
    BobMonk
    Jul 15, 2003
  2. dpackwood
    Replies:
    3
    Views:
    1,830
  3. Rajive Narain
    Replies:
    0
    Views:
    1,989
    Rajive Narain
    Sep 18, 2009
  4. Ignoramus6539
    Replies:
    2
    Views:
    231
    Colin McKinnon
    Aug 30, 2006
  5. M. Strobel
    Replies:
    1
    Views:
    228
    The Natural Philosopher
    Mar 5, 2013
Loading...

Share This Page