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

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 http://perlmonks.org/index.pl?node_id=661239 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2020-08-14 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (76 votes). Check out past polls.

    Notices?