How to get node id from URL? I want to pass a URL to a function. This function should get the node ID from the URL.

How to do this?
You can try the following code (please note that about-us is merely an example page - you can put whichever page you want here):

$url = 'about-us';
$path = drupal_lookup_path('source', $url);

if ($path) {
  $node = menu_get_object('node', 1, $path);    
  return $node-&gt;nid;
}
else {
  //Error handling in case path provided does not exist
}


The code above returns a whole node object though, which might be expensive depending on how often you run it - another option would be to run explode() on the output of drupal_lookup_path() and just take the NID that way.

References:

drupal_lookup_path();

menu_get_object();