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.
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).