Can you include PHP in a Perl file?

I have a page written in Perl by someone else. I don’t know Perl, so I wrote a PHP file that now refers to the Perl page. What I would like to do is insert a PHP file into a Perl file if a specific variable has been passed to the perl page. If I used PHP for both, I could just do

if ($_GET['sidebar']) include "embedded.php";

I know there are ways to read text files in Perl, but can I include a PHP file in a Perl file?

I assume this will not work because they are processed by different parts of the server, so there is not much hope, but maybe someone tried something like this.

+3
source share
4 answers

(HTML ..) PHP script , perl, PHP php-cli, :

-, test.pl script:

[root@www1 cgi-bin]# cat test.pl
#!/usr/bin/perl
print "This is a perl script\n";
my $output = `php test.php`;
print "This is from PHP:\n$output\n";
print "Back to perl...\n";
exit 0;

, test.php script:

[root@www1 cgi-bin]# cat test.php
<?php

echo "PHP generated this";

?>

"test.pl":

[root@www1 cgi-bin]# perl test.pl
This is a perl script
This is from PHP:
PHP generated this
Back to perl...
+13

PHP PHP::Interpreter, include. , .

+11

Perl- Perl, Perl PHP, PHP- PHP-. Perl PHP . PHP PHP- Perl, . PHP- , (, ) . PHP, PHP Perl. Perl :

 // your code before PHP call
 $php_output = `php /path/to/php/script -param1 -param2 -param3`;
 // your code after PHP call

PHP script :

<?php
// argv() is defined by PHP and contains all command line params
$params = argv();
// first index of argv is the name of the PHP  you are running.
array_shift($params);
// now you have all parameters.
// your code here generates some results.
echo $resutls;
?>

Perl, () Perl. .

+1

:

http://metacpan.org/pod/PHP::Include

HP:: Include :: Simple Parse:: RecDescent Perl- PHP Perl.

Perl PHP . ( , - XML?). - Perl , PHP Perl. PHP:: Filter:: Simple Parse:: RecDescent, PHP Perl.

:: Simple ( ), PHP Perl, Parse:: RecDescent Perl.

PHP:: Include , , PHP, .

0
source

All Articles