0

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.

1
  • Are you sure you didn't mean to ask "How can I invoke PHP code from a CGI?" Commented Jul 7, 2010 at 15:00

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks, can you please provide me an example how to code php inside cgi? so that i can see if it works and confirm if this module is installed.
@Jay, No, I do not have the time or interest to work out an example beyond what is in the distributions for those modules.
0

have you tried via Command Line like so:

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

Comments

0

Try to use PHP::Interpreter :

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.