Calling a PHP function from a Perl script.
------=_NextPart_000_006B_01CBCF62.65A61940
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
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
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- =3D-=3D-=3D-=3D=
-=3D-=3D-=3D-=3D-=3D-=3D-=3D
Thunder Rain Internet Publishing
-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D -=3D-=3D-=3D-=
=3D-=3D-=3D-=3D-=3D-=3D-=3D-
------=_NextPart_000_006B_01CBCF62.65A61940--
Re: Calling a PHP function from a Perl script.
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 [at] 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
Jim [at] Gibson.org
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: Calling a PHP function from a Perl script.
Fri, 18 Feb 2011 11:53:02 -0600 письмо от "Mike Blezien" <mickalo [at] 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.
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/