Gossamer Forum
Home : General : Perl Programming :

how to include a PHP file in a Perl file ?

Quote Reply
how to include a PHP file in a Perl file ?
I have installed a login system for my site, I have added this code to all my php scripts (at the begning),
Quote: session_start();
include("database.php");
include("login.php");

if ($logged_in <> true) {
echo "you are not logged in";
displayLogin();
exit;
}


is it possible to add this login system to my .cgi file too ?
generaly is it possible to run a PHP code in the middle of a perl script ?
if yes please tell me how .
Quote Reply
Re: [johnpaul] how to include a PHP file in a Perl file ? In reply to
perl has no PHP parser. If you want to write a PHP parser in perl, go ahead, then you will be able to include your PHP code. Otherwise, port it over.
Quote Reply
Re: [johnpaul] how to include a PHP file in a Perl file ? In reply to
Hi,

Not really, you can do:

use LWP::Simple qw/get/;
my $output = get("http://server/script.php");

and make a seperate request to pull in the php data. This isn't that efficent though, and also won't have the same headers so might not be appropriate for any session handling code.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] how to include a PHP file in a Perl file ? In reply to
Assuming that the intent is to share variables and functions between PHP and perl, it cannot be done. If you just want to run the program, there are many options.

Like I said, it's best just to port over your code (or do everything in a single language).

Quote Reply
Re: [johnpaul] how to include a PHP file in a Perl file ? In reply to
Perl 6 will likely give you some possibilities...

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...