upgraded php - now endless undefined variable warnings

Joined
12 Feb 2006
Posts
17,416
Location
Surrey
just upgraded my desktop and installed xampp which i guess comes with a later version of php than what i had previously used.

unfortunately i'm now shown with an endless list of undefined variable warnings.

everything works fine, however it's too much to ignore when trying to work on the site.

i've reduced what warnings i see, but i'm also seeing other issues like " A non-numeric value encountered" when trying to multiply a variable that's not been defined as anything yet, plus i'd prefer to see warnings as much as possible.

so i'm wondering what's best to do now?

do i really need to go through every page and define every single freaking variable before it's used?

there are situations where i have something like the following:

if x==1 then y = 2,

if a==1 then b = 3

then i have b+y+z = and the total displayed, but as sometimes x or a doesn't equal 1 then y or b wont be set as anything. this is of course causing a warning now but still works with no issues
 
Yes unfortunately though my fear is that if I reduce the error reporting, I'll miss other errors down the line unrelated to these. Is there a fix for just undefined variables do you know?
 
I assume you went to PHP 7.2 from PHP 5.X.

7 is a lot more vocal about it's errors and warnings than previous versions, either spend some time Googling how to fix them or silence it all.

Seems like yes, it is time to sort out that code, in your example use an if statement.
 
Sounds like the code could be more efficient if you have more variables than the time it took to write the post questioning if the error message really means what the error message says :p
 
Back
Top Bottom