JDesigns
JDesigns

Reputation: 2332

How can call a PHP function from Perl code?

I have a function written in PHP and would like to call this inside a CGI script. Is there any direct way to do this?

I am not sure if its even possible. The CGI script will be inside cgi-bin directory and the PHP function will be outside this folder.

Upvotes: 0

Views: 1645

Answers (3)

Liza
Liza

Reputation: 197

Try to use PHP::Interpreter :

use PHP::Interpreter;
my $p = PHP::Interpreter->new();
$p->include("some_php_include.php");
my $val = $p->somePhpFunc($perlVal);

Upvotes: 0

RobertPitt
RobertPitt

Reputation: 57268

have you tried via Command Line like so:

open DATA, "/path/to/you/bin/php you_script.php |" or die "Whoops: $!";

Upvotes: 0

Sinan Ünür
Sinan Ünür

Reputation: 118128

I guess you could try to use Inline::Interp or PHP, however, I am not sure I see the point, given the overhead involved in invoking yet another interpreter in a CGI script.

Upvotes: 2

Related Questions