All page access only to administrator in I want to restrict my page access. Only an administrator should be able to see the page.

I followed this tutorial

function example_menu() {
  $items['example'] = array(
    'title' =&gt; 'My Page',
    'page callback' =&gt; 'example_custom_page',
    'access callback' =&gt; 'example_user_has_role',
    'access arguments' =&gt; array(1, array('adminstrator')), // Argument 1 loads the user, argument 2 is the role name.
    'type' =&gt; MENU_NORMAL_ITEM,
  );

  return $items;
}


function check_user_has_role($user, $roles = array()) {
    foreach ($roles as $role) {
        if (in_array($role, $user-&gt;roles)) {
            return TRUE;
        }
    }
    return FALSE;
}


But I was able to access the URL even after I logged out. What is my mistake or is there a better way to achieve this?
I think the name of your access callback is wrong. (example_user_has_role => check_user_has_role). Also, you made a mistake on the role name (adminstrator => administrator).

Anyway, you can achieve this in a more simple way like this (avoiding the argument in the URL)

function example_menu() {
  $items['example'] = array(
    'title' =&gt; 'My Page',
    'page callback' =&gt; 'example_custom_page',
    'access callback' =&gt; 'check_user_has_role',
    'type' =&gt; MENU_NORMAL_ITEM,
  );

  return $items;
}


function check_user_has_role() {
  global $user;
  if (in_array('administrator', $user-&gt;roles)) {
    return TRUE;
  }
  return FALSE;
}