homepage Welcome to WebmasterWorld Guest from 54.235.39.132
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
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!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved