简体   繁体   中英

PHP Errors are not showing up in the browser

I am facing a strange problem. I have set up everything in php.ini file. But i can't get any errors showing up in the browser. I googled to set up the.ini file and did all the required things. But still i am not able to get error message displaying in the browser. My PHP ini settings,

display_errors = On
display_startup_errors = On
error_reporting = E_ALL | E_STRICT
log_errors = On
track_errors = On

I tried with the following code to see error message,

<?php
      require_once("sample.php");
 ?>

Actually the file sample is not available. So it must show Fatal error. But it is showing a blank page.

Can you point me out to fix this? I don't know what i am missing here.

You can also add custom error reporting to your php and test with that:

<?php
    error_reporting( E_ALL );
    ini_set( "display_errors", 1 );
    require_once( "sample.php" );
?>

If you get fatals, then something is wrong with php.ini configuration ( maybe you have multiple php.ini files? ). If you still get nothing, then php can find the file ( maybe you have some redirects set up? Maybe some strange extensions? )

I found the problem. Actually, PHP is installed with XDebug extension. So the problem is in that extension. Even i was not aware of that. Because this system was used by someone previously. I uninstalled and installed again with new supported version. It works now. Thanks and sorry for the inconvenience friends.

Try finding these words in your php.ini file

display_errors
error_reporting

change default value of display_errors from Off to On
change default value of error_reporting from XXXX to E_ERROR | E_PARSE E_ERROR | E_PARSE

Restart apache server.
Mind, It'll always show errors.

I know its an old thread, yet if someone is facing the same issue with php8 installation, use the following methods.

    <?php

      phpinfo() 

    ?>` 

and you can find the location of php.ini in the phpinfo() page , php8 when i installed i had three directories inside /etc/php/ location 7.2, 8.0, 8.1.I was using ubuntu 18.04 . Run this command to find php.ini location php -i | grep "php.ini" .Try editing the php.ini in the shown location and if it does not work, follow phpinfo() page and find the php.ini location in the page.

if you have added the following script

       <?php

       error_reporting( E_ALL );
       ini_set( "display_errors", 1 );      
       require_once("sample.php");
      
       ?>

and you are able to see the error means something is overriding the php.ini. Most likely in that case php.ini file location may be different. You might have edited the wrong php.ini file.I had to edit php.ini file in this location /etc/php/8.0/apache2 . Change display_errors directive to on in the php.ini file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM