Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off notice reporting in xampp?

Tags:

php

xampp

On a remote server there is no problem, but in localhost (xampp 3.1.) I cannot turn off reporting notices.

<?php
$Fname = $_POST["Fname"];
...

result:

Notice: Undefined index: Fname in D:\xampp\htdocs\xx\php01\form01.php on line 6

php.ini

; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_NOTICE  //shouldn't this line turn off notice reporting ?

Any suggestion ?

like image 883
qadenza Avatar asked Dec 02 '22 17:12

qadenza


2 Answers

Write this code in start of your file.

ini_set('display_errors', 0);
error_reporting(E_ERROR | E_WARNING | E_PARSE); 

Edit1

If you did not want to use above lines then you have to write @ before $_POST to suppress notices, like

$Fname = @$_POST["Fname"];

Edit 2

With this line error_reporting = E_ALL & ~E_NOTICE also change display_errors = Off although its bad programming practices.

like image 182
Noor Avatar answered Dec 21 '22 06:12

Noor


If your running XAMPP and want to turn off notices (or other features):
1. Make sure your editing the right INI file (select config from the control panel)
2. Turn display_errors=on
3. Turn error_reporting=E_ALL & ~E_NOTICE (This will only suppress notice errors)
4. Important - Make sure XAMPP is not overriding your settings further down the file (read the notice above the first set of settings)
5. Stop and Start Apache after saving the file

like image 26
MikeR Avatar answered Dec 21 '22 08:12

MikeR