Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Output PHP

by kmiles (Initiate)
on Jan 09, 2008 at 03:48 UTC ( #661239=perlquestion: print w/replies, xml ) Need Help??

kmiles has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I have several new web sites that use PHP heavily (all of our existing sites use Perl). All I want to be able to do is create a PHP template for output from a Perl program. Template is created, slurp the template into $var, replace with content using regexp, then print STDOUT "Content-type: text/html\n\n$var\n"; Problem is that <?php commands ?> are ignored when dumped this way. I've written the contents to a temp file and then output a html redirect, which works but is very messy and slow. Is there a way to output to STDOUT but have the PHP processed? Thanks for any help!

Replies are listed 'Best First'.
Re: Output PHP
by rafl (Friar) on Jan 09, 2008 at 03:53 UTC
      I've looked at this also. I just haven't been able to figure out how to use it for this case. I was hoping someone could provide an example.
Re: Output PHP
by Cody Pendant (Prior) on Jan 09, 2008 at 06:06 UTC
    Direct system() or exec() call to the PHP executable?

    Their -r flag looks like it's the equivalent of our -e flag so maybe

    system("php -r $var")
    would do it?

    Nobody says perl looks like line-noise any more
    kids today don't know what line-noise IS ...
Use Perl to output PHP template
by kmiles (Initiate) on Jan 10, 2008 at 16:21 UTC
    I posted this question the other day Thanks for the responses. I was able to use LWP::Simple to capture the output of the PHP template to a Perl $var, then do my regexp content replacement inside the $var, then output all to STDOUT.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://661239]
Approved by kyle
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2021-11-29 00:33 GMT
Find Nodes?
    Voting Booth?

    No recent polls found