Get the vocabulary ID by term or node I am going to check whether a term belongs to a designated vocabulary. 

Which function is used to get vocabulary by term or node?
In Drupal 6, if you know the taxonomy term ID, you can get the vocabulary ID by using the following code:

$term = taxonomy_get_term($tid);
$vid = $term-&gt;vid;


If you have a node ID, then you can use the following code to get the vocabulary ID of all the taxonomy terms associated with the node using the following code:

$node = node_load($nid);
$vids = array();

if (!empty($node-&gt;taxonomy)) {
  foreach ($node-&gt;taxonomy as $tid =&gt; $term) {
    $vids[] = $term-&gt;vid;
  }
}


In Drupal 7, the code would be the following:

$term = taxonomy_term_load($tid);
$vid = $term-&gt;vid;


In Drupal 7, the node property $node-&gt;taxonomy doesn't exist anymore. Instead, there is $node-&gt;field_&lt;vocabulary_name&gt;, which is an array with two different structures.


tags  


other taxonomy terms  




Using field_get_items(), you would get the taxonomy terms in the language they would be displayed, or in the language whose code is passed as argument to the function.

$items = field_get_items('node', $node, $field_name);


$node contains the node object, and $field_name the name of the taxonomy term field.

$items contains a simplified array, compared to the array contained in $node-&gt;field_&lt;vocabulary_name&gt;.