Depending on which error reporting I set, my web app either works or displays a ton of errors. I was under the impression I didn’t need to initiate variables in PHP but setting the second error reporting seems to require it. What is going here? Should I go through and initiate all my variables?
error_reporting(E_ALL ^ E_NOTICE);
error_reporting(E_ALL | E_STRICT);
You are asking about whether to suppress the warning for uninitialized variables, but the code you are posting suppresses ALL
E_NOTICEwarnings. This is not quite the same thing, but it’s as close as you can get directly to what you’re asking; there is no way to suppress only uninitialized variable notices.In a way, notices are possibly the most important warning/error messages of all because they point out potential logic errors, which are among the most difficult to identify and fix.
Given your options:
E_NOTICEwarnings.I would recommend going with #2. It’s more work upfront, but a well-timed
E_NOTICEmight just save you a whole mess of trouble one day.