Execute External Php Script & get output+errors

hi
i am trying to execute a php code

eg
$code="<?php echo "hii"; ?>

echo exec("php $code");

the above works fine when there are no errors but incase of errors it does not give error msgs
after modifying

eg
$code="<?php echo "hi ?>

exec("php $code error.php 2>&1",$output,$return);

In the above example, error.php contains the errors even wen the php script in the $code variable is correct…

Whats i need

  • Should display the output [Only when complete php script as in case of web browsers]
  • When there is no output, it should display the error msgs
  • If possible replace $code with a file [currently not working ]

Thanks
Aamir

Any one???

I have a page explaining how to display errors when using imagemagick that should work for you.

This is the one I use normaly:


$array=array();
echo "<pre>";
exec("php $code 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";