KenDRhyD Posted November 9, 2008 Share Posted November 9, 2008 I am developing on Mac OS 10.5.5 with all of the latest patches. Some time ago when I was developing some PHP code for a web site on my iMac the code would report an error and fail the page if my PHP code referenced a variable that did not exist. This was great since it allowed me to find typing errors. Since then I have upgraded my system several times, and now any reference to a non-existent variable simply results in a null value -- which makes it much more difficult to locate such problems. How can I enable, either permanently, temporarily or per execution the debug mode where references to undefined variables results in a fatal error? Quote Link to comment https://forums.phpfreaks.com/topic/132039-solved-debugging-stop-if-variable-undefined/ Share on other sites More sharing options...
genericnumber1 Posted November 9, 2008 Share Posted November 9, 2008 it's in the E_STRICT setting (which I also love!). You can just do error_reporting('E_ALL | E_STRICT'); But if you want it for every page in a non-production environment I'd do it in php.ini. Quote Link to comment https://forums.phpfreaks.com/topic/132039-solved-debugging-stop-if-variable-undefined/#findComment-686131 Share on other sites More sharing options...
wildteen88 Posted November 9, 2008 Share Posted November 9, 2008 For errors to be displayed during runtime you'll also need to to make display_errors is enabled. You can set this within your php.ini display_errors = On Or via ini_set in your scripts error_reporting(E_ALL); ini_set('display_errors', 'On'); Quote Link to comment https://forums.phpfreaks.com/topic/132039-solved-debugging-stop-if-variable-undefined/#findComment-686142 Share on other sites More sharing options...
genericnumber1 Posted November 9, 2008 Share Posted November 9, 2008 I think he was just referring to the "undefined variable" errors and "undefined offset" errors for arrays, which is in E_STRICT and not included in E_ALL. Quote Link to comment https://forums.phpfreaks.com/topic/132039-solved-debugging-stop-if-variable-undefined/#findComment-686169 Share on other sites More sharing options...
KenDRhyD Posted November 10, 2008 Author Share Posted November 10, 2008 Or via ini_set in your scripts error_reporting(E_ALL); ini_set('display_errors', 'On'); Does the ini_set() function permanently change the contents of the php.ini file, or does the change only last for the remainder of the page or the session? Quote Link to comment https://forums.phpfreaks.com/topic/132039-solved-debugging-stop-if-variable-undefined/#findComment-686432 Share on other sites More sharing options...
corbin Posted November 10, 2008 Share Posted November 10, 2008 The script execution unless changed further on. Quote Link to comment https://forums.phpfreaks.com/topic/132039-solved-debugging-stop-if-variable-undefined/#findComment-686444 Share on other sites More sharing options...
wildteen88 Posted November 10, 2008 Share Posted November 10, 2008 I think he was just referring to the "undefined variable" errors and "undefined offset" errors for arrays, which is in E_STRICT and not included in E_ALL. This is handled by E_ALL for me. Quote Link to comment https://forums.phpfreaks.com/topic/132039-solved-debugging-stop-if-variable-undefined/#findComment-686893 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.