Hi,

We just got a "virtual" server setup with PHP. When coding, if we make even the simplest of errors, say... missing a ;... we get a blank screen. If we add....

ini_set('display_errors',1); 
error_reporting(E_ALL);

That doesn't show anything either... just a blank screen.

We made a simple error test program (with very basic errors) that included these two lines at the top and tried it on a friends PHP server. His reported the problems when the page was executed.

Being this is a virtual server, we have access to most of the "setup" for it but can't find anything that could potentially be blocking error reporting.

We'd like to be able to turn these errors on and off during programming and testing... but right now, it's driving us nuts. Have to "copy" the code and run it through a PHP Code Checker online somewhere if the error isn't obvious.

Any suggestions as to where to look?

Thanks

    Which webserver are you using? If you're using Apache, and PHP was installed as an Apache module (versus a CGI/FastCGI binary), then you have the option of setting PHP directives in a .htaccess file. The bonus of doing this is that .htaccess files are parsed on-the-fly; no reboot of Apache is needed to quickly flip a value on/off as needed.

    Second option would be the php.ini configuration file. The location of this file can vary widely (read: virtually infinite number of possibilities), so your best bet would be to check a phpinfo() readout to see where the 'loaded' configuration file is coming from.

    And as for what you've already tried:

    pbrama;10979500 wrote:
    ini_set('display_errors',1); 
    error_reporting(E_ALL);
    

    That doesn't show anything either... just a blank screen.

    That's because you're probably talking about a parse error. A parse error means that PHP interpreter couldn't parse the text file you gave it into instructions it can execute.

    The point is, a parse error means that PHP can't execute your code. That includes the code where you attempt to enable error reporting.

      Thanks for the fast reply////

      According to the PHPINFO()... the SERVER_API is CGI/FastCGI.

      The file I am running is pretty straight forward....

      <?
           ini_set('display_errors',1);
           error_reporting(E_ALL);
      
       // The following line is missing the semi-colon... 
       echo "This line should have a ; at end"
      
       // The following IF code is a syntax error - missing closing )
        if ($a!=$a
        {
        }
      ?>
      

      And still not sure why one one "server" it reported the missing ; and ) and this one just shows a blank screen... so, that wouldn't make it a PARSE error would it?

        pbrama wrote:

        And still not sure why one one "server" it reported the missing ; and ) and this one just shows a blank screen

        One server has display_errors enabled, the other does not. Note that display_errors should never be enabled in the production environment - that may explain why the server in question is configured as such.

        pbrama wrote:

        so, that wouldn't make it a PARSE error would it?

        The fact that PHP can't parse it makes it a parse error. 🙂

          Ok, that makes sense.

          I checked the PHPINFO() and display_errors = OFF and error_reporting=30719 (E_ALL). I edited the PHP.INI and added display_errors=1. Checking the PHPINFO() again, it is now ON.

          Tried running that file again... same thing... blank screen.

          Any other ideas?

            Try using the full '<?php' tag instead of the '<?' short tag (which should be avoided, as should its friend <?=(expression)?>).

              Wow... that helped!!! Now I am getting, at least, the first error.

              Interesting thing, though, for the ; missing, it is listing a line # that is actually the NEXT line

              Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in /var/www/clients/client2/web1/web/testerr2.php on line 12

              Do you know, is that normal?

              I really really appreciate your help so far!!!

                pbrama wrote:

                Do you know, is that normal?

                Yes, it's normal for PHP to tell you as soon as it realizes there is an error.

                The error message didn't tell you that the error was on line #12. It told you that on line #12, PHP encountered something it wasn't expecting at that point and realized that somewhere on line #12 or above, something isn't quite right.

                  One more quick question... even though you resolved my issue....

                  Doesn't...

                  ini_set('display_errors',1); 
                  

                  Do the same as putting display_errors=1 in the PHP.INI?

                  Thanks again...

                    It does if that code actually gets executed, yes, but as I said above parse errors means PHP can't execute your code (whereas it will always load up the php.ini config values first).

                      Write a Reply...