Это похоже на работу:
<?php
$file = dirname(__FILE__) . '/test.php';
//$output will be filled with output from the command
//$ret will be the return code
exec('php -l ' . escapeshellarg($file), $output, $ret);
//return code should be zero if it was ok
if ($ret != 0) {
echo 'error:';
var_dump($output);
} else {
echo 'ok';
}