Fatal error when calling drupal_goto from hook_boot When I am trying to call drupal_goto from hook_boot I get an error:


  Fatal error: Call to undefined function drupal_goto()


What am I doing wrong and why is that happening?

My code:

function custom_mobile_redirect_boot() {
  include_once 'Mobile_Detect.php';
  $detect = new Mobile_Detect();
  if ($detect-&gt;isMobile() || $detect-&gt;isTablet()) {
    drupal_goto('http://testsite.local');
  }
}
In hook_boot() lot of APIs will not work as the required function definitions for them will not be loaded. In this case common.inc where drupal_goto() is defined is not yet included ergo you get that error. If its not possible to use hook_init() make use of Header. Check out mobile_tools module hook_boot() for more info.