Welcome Guest, Not a member yet? Register   Sign In
how to disable notices in CI
#1

[eluser]kalpesh[/eluser]
i am getting notices when i try to add google ad for mobile site.
so how to disable notices in CI.
Code:
A PHP Error was encountered
Severity: Notice

Message: Undefined index: HTTPS

Filename: views/Footer.php

Line Number: 17

A PHP Error was encountered
Severity: Notice

Message: Undefined index: HTTP_REFERER

Filename: views/Footer.php

Line Number: 23

A PHP Error was encountered
Severity: Notice

Message: Undefined index: HTTP_UA_PIXELS

Filename: views/Footer.php

Line Number: 46

A PHP Error was encountered
Severity: Notice

Message: Undefined index: HTTP_X_UP_DEVCAP_SCREENPIXELS

Filename: views/Footer.php

Line Number: 49

A PHP Error was encountered
Severity: Notice

Message: Undefined index: HTTP_X_DCMGUID

Filename: views/Footer.php

Line Number: 60
#2

[eluser]cpp643[/eluser]
in index file please comment the E_ALL line and use E_ERROR instead of it
#3

[eluser]Unknown[/eluser]
Perhaps you should try to figure out where the notices are coming from and leave the error reporting as it is, because it is telling you something helpful and will do so in the future. Didn't work with the google ads, but it seems like you're trying to access $_SERVER variable. Maybe try with the input class, for example
Code:
$this->input->server('HTTPS')
Check if the code generating notices is actually working now. If it isn't, turning off notices won't make it work. Hope this helps.
Cheers!
#4

[eluser]Ace_ov_Spade[/eluser]
I disabled notice and warning for some of my controllers

Code:
function Booking()
    {
        parent::Controller();    
        session_start();
        error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
    }
#5

[eluser]WanWizard[/eluser]
You disable notices by fixing your faulty code, not by supressing them. Doing that is a recipe for disaster.
#6

[eluser]tonanbarbarian[/eluser]
You really want to fix and notices, warning or errors in your code.
This is because PHP takes time to process any errors. It might only be a fraction of a second, but if you have hundreds of errors, or your server is under load, each of those errors just slows things down further

if you are that way inclined (and most people probably arent) you can test it yourself by making a for loop with 1000000 iterations and having an error in the loop and see how long it takes to process, then take the error out and see the difference.
It is an extreme example but it does prove the point.

In fact i think using @ to suppress the errors does not really speed things up at all either
#7

[eluser]WanWizard[/eluser]
Yes, but not because if this reason.

If you for example reference an array index in your code, you do this for a reason. If it doesn't exist, you will get a notice, but your script continues with a value for that array element that PHP 'invented', and that can cause your application to do something completely different then what you intended.

Every notice, warning or error issued by PHP is a BUG in your code, and should be rectified, not ignored.

If you don't, you produce sloppy and unpredictable code, and you wouldn't be a programmer that I would like to employ.




Theme © iAndrew 2016 - Forum software by © MyBB