richard99 Posted December 20, 2006 Share Posted December 20, 2006 Is there a way to get PHP to throw an error or warning if I reference a variable that has never been defined? For example, if I have the following code:$a = 1;$c = $a + $b;I would like to get an error telling me that $b is undefined. Can this be done? Link to comment https://forums.phpfreaks.com/topic/31399-undefined-variables/ Share on other sites More sharing options...
wildteen88 Posted December 20, 2006 Share Posted December 20, 2006 Enable display_errors and make sure error_reporting is set to E_ALL in the php.iniYour should now get a Notice message a bit like the following:[code]Notice: Undefined variable: [variable name here] in [path of script] on line [line number here][/code] Link to comment https://forums.phpfreaks.com/topic/31399-undefined-variables/#findComment-145354 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.