By oshirowanen

2011-03-25 20:55:39 8 Comments


I have now removed the following from the .php file:

<?php error_reporting( E_ALL ); ?>

I have set display_erros in php.ini as follows:

display_errors = On

error reporting is set to the following in php.ini

error_reporting = E_ALL | E_STRICT

After restarting apache, I still get no errors/warnings.


I have changed error_reporting in php.ini from:

error_reporting = E_ALL & ~E_DEPRECATED


error_reporting = E_ALL | E_STRICT

After which I restarted apache, e.g.

/etc/init.d/apache2 restart

But the page will still not display errors/warnings of any kind.


The following script is generating a warning because the $err being inside the if statement. Why is this warning not being displayed on the PHP page in a web browser? I have to look at apache logs to see the warning. Also, if I deliberately change the "insert into" to "delete into", it does not display an error on the PHP page. Why are the errors not displaying on the actual PHP page?

    error_reporting( E_ALL );

        <link rel="icon" type="image/png" href="favicon.ico">

            if( $_SERVER['REQUEST_METHOD']=='POST' ) {
                $err = array();

                if( empty( $_POST['display_name'] ) ) $err[] = "display name field is required";
                if( empty( $_POST['email'] ) ) $err[] = "email field is required";
                if( empty( $_POST['password'] ) ) $err[] = "password field is required";

                if( !$err ) {
                    try {
                        $DBH = new PDO( "mysql:host=localhost;dbname=database1", "user", "pass" );
                        $DBH -> setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

                        $STH = $DBH -> prepare( "delete into table1 (display_name, email, password) values ( :display_name, :email, :password )" );

                        $STH -> bindParam( ':display_name', $_POST['display_name'], PDO::PARAM_STR, 100 );
                        $STH -> bindParam( ':email', $_POST['email'], PDO::PARAM_STR, 100 );
                        $STH -> bindParam( ':password', $_POST['password'], PDO::PARAM_STR, 100 );

                        $STH -> execute();

                        $STH = $DBH -> prepare( "delete into table2 ( username, status, users_id ) values ( :username, :status, :users_id )" );

                        $strStatus = 1;

                        $STH -> bindParam( ':username', $_POST['display_name'], PDO::PARAM_STR, 100 );
                        $STH -> bindParam( ':status', $strStatus, PDO::PARAM_INT, 1 );
                        $STH -> bindParam( ':users_id', $_POST['referer'], PDO::PARAM_INT, 1 );

                        $STH -> execute();

                        $DBH = null;
                    } catch( PDOException $e ) {
                        echo $e -> getMessage();

                    header( "Location: ".$_SERVER['PHP_SELF'] );
                } else {
                    foreach( $_POST as $key => $val ) {
                        $form[$key] = htmlspecialchars($val);
            } else {
                $form['display_name'] = $form['email'] = $form['password'] = '';

        <?php foreach( $err as $line ) { ?>
        <div style="error"><?php echo $line; ?></div>
        <?php } ?>


        <form method="post">
            referers id:<br />
            <input type="text" name="referer" /><br /><br />

            name:<br />
            <input type="text" name="display_name" value="<?php echo $form['display_name']; ?>" /><br /><br />

            email:<br />
            <input type="text" name="email" value="<?php echo $form['email']; ?>" /><br /><br />

            password:<br />
            <input type="text" name="password" value="<?php echo $form['password']; ?>" /><br /><br />

            <input type="submit" value="register" />


@vkp 2017-02-10 09:18:44

Php errors can be displayed as any of below methods:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

For more details:

@Nabi K.A.Z. 2017-07-23 15:38:02

The display_errors = on; in PHP file has syntax error.

@Suresh Maurya 2018-05-12 14:06:44

You can see detailed description here.

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);

// Report all PHP errors (see changelog)

// Report all PHP errors

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);


  • 5.4.0 E_STRICT became part of E_ALL

  • 5.3.0 E_DEPRECATED and E_USER_DEPRECATED introduced.

  • 5.2.0 E_RECOVERABLE_ERROR introduced.

  • 5.0.0 E_STRICT introduced (not part of E_ALL).

@rinjan 2015-10-31 08:24:50

set these on php.ini

;display_startup_errors = On
display_errors =on
html_errors= on

From your php page use suitable filter for error reporting.


Filers can be made according to requirement.


@John Magnolia 2012-11-15 17:05:58

Straight from the php.ini file:

; Error handling and logging ;

; This directive informs PHP of which errors, warnings and notices you would like
; it to take action for. The recommended way of setting values for this
; directive is through the use of the error level constants and bitwise
; operators. The error level constants are below here for convenience as well as
; some common settings and their meanings.
; By default, PHP is set to take action on all errors, notices and warnings EXCEPT
; those related to E_NOTICE and E_STRICT, which together cover best practices and
; recommended coding standards in PHP. For performance reasons, this is the
; recommend error reporting setting. Your production server shouldn't be wasting
; resources complaining about best practices and coding standards. That's what
; development servers and development settings are for.
; Note: The php.ini-development file has this setting as E_ALL. This
; means it pretty much reports everything which is exactly what you want during
; development and early testing.
; Error Level Constants:
; E_ALL             - All errors and warnings (includes E_STRICT as of PHP 5.4.0)
; E_ERROR           - fatal run-time errors
; E_RECOVERABLE_ERROR  - almost fatal run-time errors
; E_WARNING         - run-time warnings (non-fatal errors)
; E_PARSE           - compile-time parse errors
; E_NOTICE          - run-time notices (these are warnings which often result
;                     from a bug in your code, but it's possible that it was
;                     intentional (e.g., using an uninitialized variable and
;                     relying on the fact it is automatically initialized to an
;                     empty string)
; E_STRICT          - run-time notices, enable to have PHP suggest changes
;                     to your code which will ensure the best interoperability
;                     and forward compatibility of your code
; E_CORE_ERROR      - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING    - warnings (non-fatal errors) that occur during PHP's
;                     initial startup
; E_COMPILE_ERROR   - fatal compile-time errors
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
; E_USER_ERROR      - user-generated error message
; E_USER_WARNING    - user-generated warning message
; E_USER_NOTICE     - user-generated notice message
; E_DEPRECATED      - warn about code that will not work in future versions
;                     of PHP
; E_USER_DEPRECATED - user-generated deprecation warnings
; Common Values:
;   E_ALL (Show all errors, warnings and notices including coding standards.)
;   E_ALL & ~E_NOTICE  (Show all errors, except for notices)
;   E_ALL & ~E_NOTICE & ~E_STRICT  (Show all errors, except for notices and coding standards warnings.)
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

For pure development I go for:

error_reporting = E_ALL ^ E_NOTICE ^ E_WARNING

Also don't forget to put display_errors to on

display_errors = On

After that restart your server for apache on Ubuntu:

sudo /etc/init.d/apache2 restart

@Bell 2016-10-29 00:02:47

"PHP 6.0.0"? Heh :-)

@Lucas 2019-04-04 21:54:54

“For pure development @JohnMagnolia go[es] for: error_reporting = E_ALL ^ E_NOTICE ^ E_WARNING.” Are the ^ symbols concatenating the three options? If so, doesn’t E_ALL already include E_NOTICE and E_WARNING?

@Rajesh Patel 2016-01-14 11:56:35

I was able to get all error via below code:-


@txyoji 2011-03-25 21:03:08

Display errors could be turned off in the php.ini or your Apache config file.

You can turn it on in the script:

ini_set('display_errors', 1);

You should see the same messages in the PHP error log.

@oshirowanen 2011-03-25 21:10:08

Do I need to restart apache after changing the php.ini file?

@Elangovan 2014-12-03 11:55:44

already this question has been posted…

@jave.web 2014-12-08 22:04:55

@oshirowanen ini_set() does not actually change the php.ini file, the script only "acts" like it is set like that in php.ini... From manual: Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution , and will be restored at the script's ending .

@Ravi Dhoriya ツ 2015-03-12 08:32:37

I don't know how many times I came to same answer. You helped me a lot. Thank you! :)

@Nick Rolando 2016-07-21 18:28:17

@Charles Why would E_ALL remove E_NOTICE? Doesn't E_ALL by itself including everything, including E_NOTICE?

@txyoji 2016-07-26 21:05:52

@NickRolando It doesn't. My original answer removed E_NOTICE messages. Charles took me to task and I edited the answer.

@Claudiu Creanga 2016-08-07 12:50:16

the only way to show parser errors is to edit the php.ini file. ini_set will not work.

@Luka 2017-05-01 19:07:36

I always do development in production so is it good idea to turn on E_ALL but disable display errors, it will still log them in error_log right?

@Daniel W. 2018-11-28 16:32:14

@txyoji of course Nick is right. E_ALL does include E_NOTICE.

Related Questions

Sponsored Content

33 Answered Questions

[SOLVED] Reference - What does this error mean in PHP?

14 Answered Questions

[SOLVED] UTF-8 all the way through

26 Answered Questions

[SOLVED] How do I get PHP errors to display?

20 Answered Questions

[SOLVED] Xcode warning: "Multiple build commands for output file"

16 Answered Questions

[SOLVED] PHP parse/syntax errors; and how to solve them?

3 Answered Questions

[SOLVED] php script echoing part of the php instead of what intended

  • 2012-07-30 04:02:38
  • Bundy
  • 274 View
  • 2 Score
  • 3 Answer
  • Tags:   php mysql pdo

24 Answered Questions

[SOLVED] How do I address unchecked cast warnings?

0 Answered Questions

html 5 input type email $_post empty when submit

  • 2014-05-24 17:47:30
  • Ignatius Samuel Megis
  • 428 View
  • 0 Score
  • 0 Answer
  • Tags:   php html5 post

Sponsored Content