The Savvy Few: Accessing the current node ID in Drupal
From time to time you just need the node ID of the current node to get things done. In Drupal 7 you simply used the arg() function to do this, this approach no longer works for Drupal 8 and onwards because arg() is deprecated.