PHP: Hiding Errors

I was running into a problem with undefined index errors. You’ll get that if you do seomthing like:

echo $_GET['name'];

when there is no $_GET['name']. One option is to check to make sure $_GET['name'] is set like

if (isset($_GET['name'])) {
echo $_GET['name'];
}

But if you’re feeling lazy, you can leave your code as is and just add this at the top of your file

error_reporting(E_ALL ^ E_NOTICE);

Alternatively, turning off those notices is a setting you can adjust in .ini file, but if you don’t have access to that file, then just putting that error_reporting line in your code will suffice
[found on experts exchange thread]

Comments are closed.