How to call a function when a node is being viewed?
You can implement hook_node_view()


  Act on a node that is being assembled before rendering.


e.g.

function MYMODULE_node_view($node, $view_mode, $langcode) {
  if ($node-&gt;type == 'the_type' &amp;&amp; $view_mode == 'full') {
    // Call your function here.
    my_function($node);
  }
}