Get Node ID from URL (within block)

Categories:

if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
  $nid = arg(1);
}