Question

How to turn off this error in wamp:

notice undefined offset

I'd like to turn of just this error, but not all errors.

Was it helpful?

Solution

There are two issues at work here. One is what errors PHP reports, and the second is whether or not it displays those errors on the page (as opposed to the apache error log). If you'd like to turn off just NOTICES:

<?php
error_reporting(E_ALL & ~E_NOTICE);
?>

If you'd like to report the notices to your error log but not display them to the user, do this:

<?php
ini_set('display_errors','off');
?>

Note that turning off display errors will stop displaying ALL errors to the end user, and you'll need to look at the error log, usually located in /var/log/httpd/error_log to see any errors while testing.

OTHER TIPS

Have a look at error_reporting().

You could e.g. set the error reporting to

error_reporting(E_ERROR | E_WARNING | E_PARSE)

But better would be to actually check what is the cause of the Notice and fix it. Then you are on the save side.

E_NOTICE
Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.

(If you can't fix the code...) You can exclude notices by setting an reporting level x & ~E_NOTICE, e.g.

<?php error_reporting( error_reporting() & ~E_NOTICE );

or in your php.ini (or similar)

error_reporting=E_ALL & ~E_NOTICE

php.ini => error_reporting = E_ALL & ~E_NOTICE

error->notice undefined offset

main thing is remove the error on your script.Programmer always wish to design program which is error free instead of error hiding.

The array vales are not set, so when PHP is trying to access the value of those array keys it encounters an undefined offset.

$new_array = array('1','2','3');//If I have an array
//We can now access:
$new_array[0];
$new_Array[1];
$new_array[2];
//If we try and access
$new_Array[3];

we will get the same error-->error->notice undefined offset

 error_reporting(E_ALL);
 ini_set('display_errors', 'On');
 ini_set('html_errors', 'Off');

:D

Go to This direction on windows OS C:\wamp\bin\apache\Apache2.4.4\bin Then open php.ini file by any editor recommended [sublime] in 514 line just paste this two lines.

;error_reporting = E_ALL
error_reporting = E_ALL & ~E_NOTICE

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top