$terms
is an array of objects. You must select one of the array entries before you can reference its properties (fields).
This will print the ‘name’ of the first object (index zero):
if ($terms) {
echo $terms[0]->name;
}
This will print all the ‘name’ fields:
if ($terms) {
foreach( $terms as $term )
echo $term->name;
}