Page 1 of 1

Apache user doesn't seem to get parse error output.

Posted: Tue Sep 25, 2007 4:31 am
by impulse()
The PHP version I use at work doesn't give me any error information back when a PHP has syntax errors but my setup at home does. So I've wrote an online syntax checker that basically uploads a file to my box then runs 'php -l <uploadedFile>' and returns the error it receives.
The only problem is that it's only returning part of the error, which is the part I don't need. I would like it to include the line number and type of error, but it's only returning 'Errors parsing <file>'
I thought t his was due to the whole output not being stored in the variable but I ran some other system commands that have multiple line output and they display fine.

So at a guess it looks like the Apache user doesn't get the full error message, unless you can spot something in this code?

Code: Select all

<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

<?php

if($_POST) {

  $fName = $_FILES['uploadedfile']['name'];
  $tName = $_FILES['uploadedfile']['tmp_name'];
  $fSize = $_FILES['uploadedfile']['size'];

  $tPath = "/var/www/html/syntaxCheck/tmp/{$fName}";

  if(move_uploaded_file($tName, $tPath)) {
    system("php -l {$tPath}");
  }
  else
    echo "Didn't work";

}
Can anybody here offer any suggestions. I don't want a hoggy Java PHP editor with a syntax checker, which is why I've chose this route. I use a shell to do my editing so having to move files from server to desktop then load an editor and then syntax check it doesn't seem appealing.


Regards,

Posted: Tue Sep 25, 2007 5:32 am
by superdezign
That seems... pointless. The server at your job is probably set up to log errors instead of output them to the browser, and you could easily change that with ini_set() and error_reporting().

Posted: Tue Sep 25, 2007 5:39 am
by impulse()
I've tried

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', 1);
But without success.

Posted: Tue Sep 25, 2007 5:53 am
by superdezign
Maybe they have other options in their php.ini set up that prevent you from seeing errors... I'd discuss it with the people who set it up. Also, you may just want to check the error logs.

Posted: Tue Sep 25, 2007 9:34 am
by feyd
Parse errors happen well before code in the script is run. You need to set the display_errors setting at the directory level or initialization file if possible. Otherwise, you need to talk to the server admin or set up your own local mirror of the codebase to test on your machine.