[development] low hanging fruit for Drupal 6: variable defaults

Gabor Hojtsy gabor at hojtsy.hu
Thu May 3 09:57:10 UTC 2007


Wim Leers wrote:
> One use case is: on the settings page you set the default to a certain 
> value, for example an empty string. But elsewhere in your code, you set 
> the default to NULL, because then you can just do:
> 
>     $var = variable_get('some_var', NULL);
>     foreach ($var as $key => $value) { ..}
> 
> without having to check if $var is the empty string. Because using NULL 
> will immediately end the foreach loop and an empty string would generate 
> an error.
> Simple use case, but again a bit shorter!
> 
> I'll do this one :)

So you break your code once the user saves the settings page. Do you 
present this as a viable use case?

Gabor


More information about the development mailing list