lundi 23 mars 2015

Will turning error reporting and error display on and off throughout the stack cause a problem with PHP


I want to turn error reporting and error display on and off for different parts of the same framework (same stack and scope).


ini_set('display_errors', 'On'); Changing to 'Off'.

error_reporting(-1); Changing to 0.


Simple summary: A bunch of PHP files are included with error display/reporting on, then further files are included with error display/reporting off.




I have tested and it works, by using a conditional test on an undefined variable to return a notice:

if ($var == "foo") { echo "bar";}.

Will never echo "bar"; And will display Notice: Undefined variable $var if error display is "On".


This test code is placed in the 1st file with error display turned on, then a 2nd file is included from within the 1st file, 2nd file has same test code and error display off.

"Undefined var" Notice is displayed for 1st file, but not 2nd file - as desired.


The same test code with error reporting turned on and off also returns the desired results.




So I know it "works" and can turn error reporting and error display on and off as needed throughout.

However, I want to know if there are there any potential issues with PHP by doing this within the same scope?


I'm not asking if this is a good idea, but if PHP or something else will trip itself up somehow by doing this.





Aucun commentaire:

Enregistrer un commentaire