-2

I have a perl file and it has some useful variables. And I have to use those variables in a php file. I searched every where to find out how to include perl variables in to a php file.But every place is telling that "passing php vars to perl". But I want to do is vice versa of that.

2 Answers 2

1

2 possibilies depending on your workflow:

1) call script from command line - then you have to pass the variables as follow:

system('php /path/to/script.php arg1 arg2');

in script you receive arguments:

<?php
// $argv[0] is path to your script
$argument1 = $argv[1];
$argument2 = $argv[2];
?>

2) call script over url (an webserver):

use LWP::Simple;
get('http://localhost/path/to/your/script.php?firstvar=firstcontent&secondvar=secondcontent');
#OR on linux
system('wget http://localhost/path/to/your/script.php?firstvar=firstcontent&secondvar=secondcontent');

in script you receive arguments:

<?php
  print_r($_GET);
?>
1

You either pass them as command line arguments (e.g. via system) or you embed PHP in your Perl (e.g. with the PHP module).

1
  • if your answer has more information,that's will help others too Aug 9, 2013 at 6:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.