syntax check on the command line

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

It would be great if anyone could help me with this problem:
I want to check the syntax of my php code. Therefore I use the command
line function PHP -l, the structure is similar to the following code
(example from the php Manual.) The Problem is: I read from the standard
output with
echo stream_get_contents($pipes[1]);
this function is available only from PHP version 5, but I must write
for version 4.3.0. Which way could it be solved? I don't want to use a
temporary file. Please give me a hint.
Tanks, Karina

$descriptorspec = array(
   0 => array("pipe", "r"),  // stdin is a pipe that the child will
read from
   1 => array("pipe", "w"),  // stdout is a pipe that the child will
write to
   2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file
to write to

$cwd = '/tmp';
$env = array('some_option' => 'aeiou');

$process = proc_open('php', $descriptorspec, $pipes, $cwd, $env);

if (is_resource($process)) {
   // $pipes now looks like this:
   // 0 => writeable handle connected to child stdin
   // 1 => readable handle connected to child stdout
   // Any error output will be appended to /tmp/error-output.txt

   fwrite($pipes[0], '<?php print_r($_ENV); ?>');

   echo stream_get_contents($pipes[1]);

   // It is important that you close any pipes before calling
   // proc_close in order to avoid a deadlock
   $return_value = proc_close($process);

   echo "command returned $return_value\n";


Site Timeline