How can I call a PHP script from a Perl script and get its output as a variable?
Using the backtick operator:
my $phpOutput = `/usr/bin/php-cli your-script.php`;
Note that you may have to edit the path to point to your php
executable.
If you want to have the output as a stream you can also open
with a pipe (Perl <3):
open PHPOUT, "/usr/bin/php-cli your-script.php|";
while (<PHPOUT>) {
# do something with the current line $_
}
See perldoc -f open.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With