How to implement a hook?
The details for how to implement a hook varies from one hook to another.

One of the easiest examples though, is hook_init(). Hook init is a generic way of saying "Do something on every un-cached page load". The _un_cached part is important, if you are logged out when testing this, probably nothing will happen.

In a module file named "my_module.module", one would implement hook_init like this

&lt;?php
my_module_init() {
}


To make something actually happen, we can add a call to drupal_set_message().

&lt;?php
my_module_init() {
  drupal_set_message('Hello Drupal!');
}


If you have Devel installed, a common way to do debugging could look something like this:

&lt;?php
my_module_init() {
  dpm(menu_get_item());
}


For more details and examples, see What is the basic concept behind hooks?