popcornplya Posted February 13, 2009 Share Posted February 13, 2009 Is there a point in declaring an array? like $test = array(); $test[] = 'whatever'; even though it works without it and what is the difference between if(!$test) and if(!isset($test)) Link to comment https://forums.phpfreaks.com/topic/145020-couple-of-questions/ Share on other sites More sharing options...
samshel Posted February 13, 2009 Share Posted February 13, 2009 defining an array - it is a good standard practise to do so. - if there is already a variable with the same name, it will clean it. if(!$test) - will fail if $test is not set or 0 or false or null. and if(!isset($test)) - will fail only when $test is not set. Link to comment https://forums.phpfreaks.com/topic/145020-couple-of-questions/#findComment-760971 Share on other sites More sharing options...
printf Posted February 13, 2009 Share Posted February 13, 2009 Anytime you don't define something and try to use it, you will get some kind of warning / notice. It's like using coding shortcuts, just because you can doesn't mean you should. Code presentation is as important as code logic, especially when developing a full scale applications! Link to comment https://forums.phpfreaks.com/topic/145020-couple-of-questions/#findComment-760976 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.