What are Hooks in Drupal

Hooks are one of the ways for modules to interact with contributed modules or Drupal core subsystems.


Hooks allow modules to alter and extend the behavior of Drupal core, or another module. 
Using hooks developer can change how core or another module works -- without changing the existing code.


Hooks are used for a variety of tasks including preprocessing variables for template files (hook_preprocess()), altering lists of information (hook_tokens_alter(), hook_views_data_alter()), and manipulating forms (hook_form_alter()) amongst other things. This page lists all the hooks provided by core.


Modules can define additional hooks of their own. For example the Flag module defines hook_flag_options_alter(), which can be used by modules that want to alter an existing flag's default options. Most modules that define hooks will also provide documentation about them. This documentation is located in a *.api.php file.


Write a program in PHP to reverse a number

A number can be written in reverse order. For example 12345 = 54321 <?php   $ num = 23456;   $ revnum = 0;   while ($ num > 1)   {   $...