foreach ($vars['node']->taxonomy as $term) {
$vars['taxonomy_classes'] .= ' taxonomy-' . $term->tid;
}

the code is from someone , how i know the $term is an object. in drupal, how i know which variable is an object? thank you.

Comments

Raf’s picture

You print a var_dump of it. That'll tell you whether it's an object, an array, a string, an int, a bool, ... and you'll get type and value of all contents (each value of an array / each property of an object)

Eg:

<?php
print var_dump($term);
?>
yelvington’s picture

Install the devel module and use its nifty functions:

https://ratatosk.backpackit.com/pub/1836982-debugging-drupal

pbarnett’s picture

Very briefly, the PHP function is_object($var) will return true if $var is an object and false otherwise,