| Embedding PHP within PERL How to embed PHP code within a CGI-PERL script |
webtechi2010

msg:4373258 | 2:57 pm on Oct 11, 2011 (gmt 0) | Facing a strange problem, not sure if anybody faced similar issue. Earlier I had a static content website which comprised of html files. In some of the pages I was using embedded PHP codes, which was running fine. Now I have changed the architecture from static to dynamic as below. http://example.com/category/subcategory.html is internally redirecting to http://example.com/cgi-bin/display.pl?category=subcategory thanks to .htaccess Problem is now my embedded PHP codes are not getting executed, and writing the PHP content in PERL is not a valid option here. How can I execute my old PHP code snippets from within the PERL scripts over apache ? Please help. Thanks in advance.
|
janharders

msg:4373266 | 3:13 pm on Oct 11, 2011 (gmt 0) | If you're using Apache2 and you can modify the server configuration, you might be able to change php's mode of operation to a filter instead of a content module, that way, cgi-scripts could output php-code and it would be parsed and run by php.
|
rocknbil

msg:4373283 | 3:59 pm on Oct 11, 2011 (gmt 0) | | writing the PHP content in PERL is not a valid option here. |
| Can you pull out the PHP code as a file of it's own and run a system or exec on it? So if you have <?php echo 'Hello World'; ?> You'd put that in a file like hello.php and could do one of these in the perl script. system('hello.php'); exec('hello.php'); $response = `hello.php`; print $response; If it's a remote php, just use a fully qualified URL. Another option, which shouldn't be necessary, is to cURL it.
|
DrDoc

msg:4385619 | 5:50 pm on Nov 10, 2011 (gmt 0) | There's the PHP::Interpreter module on CPAN. It works great!
|
|
|