Turn off display errors using file “php.ini”

前端 未结 12 1429
春和景丽
春和景丽 2020-11-28 06:59

I am trying to turn off all errors on my website. I have followed different tutorials on how to do this, but I keep getting read and open error messages. Is there something

12条回答
  •  盖世英雄少女心
    2020-11-28 07:44

    It's been quite some time and iam sure OP's answer is cleared. If any new user still looking for answer and scrolled this far, then here it is.

    Check your updated information in php.ini file

    Using Windows explorer:

    C/xampp/php/php.ini
    

    Using XAMPP Control Panel

    1. Click the Config button for 'Apache' (Stop | Admin | Config | Logs)
    2. Select PHP (php.ini)

    Can i create my own phpinfo()? Yes you can

    1. Create a phpinfo.php in your root directly or anywhere you want
    2. Place this
    3. Save the file.
    4. Open the file and you should see all the details.

    How to set display_errors to Off in my own file without using php.ini

    You can do this using ini_set() function. Read more about ini_set() here (https://www.php.net/manual/en/function.ini-set.php)

    1. Go to your header.php or index.php
    2. add this code ini_set('display_errors', FALSE);

    To check the output without accessing php.ini file

    $displayErrors = (ini_get('display_errors') == 1) ? 'On' : 'Off';
    $PHPCore = array(
        'Display error' => $displayErrors
        // add other details for more output
    );
    foreach ($PHPCore as $key => $value) {
        echo "$key: $value";
    }
    

提交回复
热议问题