I have an external php script named external.php
which includes this:
<?php
echo 'External Output';
?>
When I run that on command line with command:
php external.php
I get output as
External Output
But when the same script I execute from my browser's php file named index.php
which has this code:
<?php
$exe=exec('php external.php',$out,$ret);
print_r($out);
?>
Then I get no output.
When I modify it as:
<?php
$exe=exec('php external.php 2>&1',$out,$ret);
print_r($out);
?>
Then I get this output:
php: /opt/lampp/lib/libxml2.so.2: version `LIBXML2_2.9.0' not found (required by php)
My question is, how can I execute that "external.php" file in commandline from index.php and get output on my browser (i.e. on index.php) ? I have tried system() function too, it doesn't work as well.
Edit:
I cannot include
the external.php in index.php because external.php can take lot of time to execute (more than 10 hours).
Edit#2 Solved it, giving the full path to PHP solved the problem.
Here is an example:
<?php
$exe=exec('full/path/to/php /full/path/to/external.php',$out,$ret);
print_r($out);
?>
Thankyou Oleg and Scopey for giving me some hint help.