Monday, December 19, 2011

variable_get in drupal

$set = variable_get (‘name’,’defaultvalue’);

Variable get will retrieve the value from drupal variable table

If  ‘name’ is not there in drupal variable table this function will return the ’defaultvalue’.

This function will return serialized data.

If it return more than one value inside the serialized data then use unserialize() function to convert the serialized data into array.

If it contains only one value then you can fetch it directly i.e. the returned value will get saved to $set directly.

No comments:

Post a Comment