In some situations, I need the site name of a Drupal 6 site which is given while installation of the site.

How can I achieve it?


In both Drupal 6 and Drupal 7, you can use variable_get. The CMI initiative will likely deprecate this function in Drupal 8.

$name = variable_get('site_name', '');

Notice the blank '' at the end, which is the "default" value, in case a variable isn't defined.

| improve this answer | |
  • In Drupal 6, variable_get() has a required second parameter: $default. If you leave this required parameter off, you may get PHP warnings (depending on the PHP error level configured on your server). – smokris Feb 26 '12 at 18:12
  • Good point, added this. – Letharion Feb 27 '12 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.