Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling a PHP function from a Perl script.

558 views
Skip to first unread message

Mike Blezien

unread,
Feb 18, 2011, 12:53:02 PM2/18/11
to Perl List
Hello,

this is kinda of a crossover to PHP which I'm not that fimilar with.

I have a Perl script that needs to call up a specific function from a PHP script, Entry.php calls "Social_preformPost()" function. I simply need to pass 2 variables to this function, SocialpreformPost($id,$message)

My question is do I need to use the require "./Entry.php" then call the function similar to the way you'd call a regular sub routine or how is this done?

thx's

Mike(mickalo)Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Jim Gibson

unread,
Feb 18, 2011, 1:28:42 PM2/18/11
to Mike Blezien, Perl List
At 11:53 AM -0600 2/18/11, Mike Blezien wrote:
>Hello,
>
>this is kinda of a crossover to PHP which I'm not that fimilar with.
>
>I have a Perl script that needs to call up a specific function from
>a PHP script, Entry.php calls "Social_preformPost()" function. I
>simply need to pass 2 variables to this function,
>SocialpreformPost($id,$message)
>
>My question is do I need to use the require "./Entry.php" then call
>the function similar to the way you'd call a regular sub routine or
>how is this done?

Perl programs are compiled and executed by a Perl interpreter ('perl'
on most systems). PHP programs are compiled and executed by a PHP
interpreter ('php' or as part of a web server). Since the languages
have different syntax, modules written in one language will not
execute by the interpreter of the other language.

Your choices include:

1. Rewrite the PHP module in Perl. This is best for long-term use.

2. Find a PHP interpreter written in Perl. See
<http://search.cpan.org/search?m=all&q=PHP&s=11>

3. Call the PHP interpreter as an external process from your Perl
program., e.g., "my @php_output = qx(php myprogram.php);" You will
have to write a main PHP program to call the desired routine and
return the results appropriately.

I have never used PHP, so can't advise further.

Good luck.

--
Jim Gibson
J...@Gibson.org

terry peng

unread,
Feb 18, 2011, 10:11:55 PM2/18/11
to beginners


Fri, 18 Feb 2011 11:53:02 -0600 письмо от "Mike Blezien" <mic...@frontiernet.net>:

> Hello,
>
> this is kinda of a crossover to PHP which I'm not that fimilar with.
>
> I have a Perl script that needs to call up a specific function from a PHP
> script, Entry.php calls "Social_preformPost()" function. I simply need to pass
> 2 variables to this function, SocialpreformPost($id,$message)
>
> My question is do I need to use the require "./Entry.php" then call the
> function similar to the way you'd call a regular sub routine or how is this
> done?
>

You can call the PHP script from command line and pass the arguments to it, like:

system("php","abc.php",$arg1,$arg2);

But you still have to modify the PHP function to make it executable from the command line.

So it's better rewrite the PHP with Perl and things get easy.

Regards.

0 new messages