You can't (at least not directly). Don't forget that multiple taxonomy terms may have the same name so they need to be identified by their tid
or you'd get clashes.
You have a couple of options to load a taxonomy term by name, but for each you'll need to know the vid
of the term's vocabulary.
The first option is to use the deprecated $conditions
parameter of the taxonomy_term_load_multiple()
function:
$terms = taxonomy_term_load_multiple(array(), array('name' => 'online', 'vid' => $vid));
$first_term = array_shift($terms);
$tid = $first_term->tid;
As you can see it's limited to loading just one term at a time.
The second (much better) way is to use an EntityFieldQuery
:
$terms = array(
'online',
'offline',
'pre-online'
);
$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'taxonomy_term')
->propertyCondition('vid', $vid)
->propertyCondition('name', $terms, 'IN');
$results = $query->execute();
if (isset($results['taxonomy_term'])) {
// Get an array of tids
$tids = array_keys($results['taxonomy_term']);
}
That way you can load multiple terms in one go, and take advantage of non-SQL field storage solutions if you need to.
If you're worried about speed you could also go directly into the taxonomy_term
table to get this data; but I don't advise doing this unless you really know what you're doing.