Link to home
Start Free TrialLog in
Avatar of rascal
rascalFlag for United States of America

asked on

How to set php.ini so undeclared variables break a page

I am currently running a PHP on Windows, but when I post my web pages to the live site, they are running on a Linux box.

The problem: When I code my php to make use of an undeclared variable (such as $sSelectedFilterProvince below), my local environment runs it just fine (even though it's obviously a bug because I did not declare $sSelectedFilterProvince earlier and set it to a value).
But in the live environment the code below just times out the page after about 2 minutes with a cryptic message.

What I would like to do is to set my php.ini file setting so that I encounter that same hang problem on my local environment before I post the code to the live site. I am assuming there's some type of setting that I can set to make this happen, but in looking at the various setting options in my local copy of php I don't see any particular setting that might be the one.

Any clues as to how I might recreate this environment on my local system?

Many thanks!

if ($sSelectedFilterProvince=="Alberta") 
{
    ... do something...
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, see if you can use the same version of PHP as your live site.
Avatar of rascal

ASKER

Thanks Dave,
That worked - it showed me a bunch of just regular inconsequential notices, but it did also highlight the missing variable definition!
You're welcome.  I use that even in production because I need the code to work and I need to know if something doesn't work.
Avatar of rascal

ASKER

But doesn't that flood the screen with a bunch of inconsequential notices? It does on my screen. Even with that particular problem fixed.
flood the screen...
Not necessarily.  You can use these settings to suppress the messages and still keep the log:

ini_set('display_errors', FALSE);
ini_set('log_errors', TRUE);
But doesn't that flood the screen with a bunch of inconsequential notices? It does on my screen.
Not on my sites.  I fix even the 'inconsequential notices' so they won't show up as errors later.