Create taxonomy term with code I want to know how i can create taxonomy term programmatically.

I have this code

$term = new stdClass();
$term-&gt;name = ‘Term Name’;
$term-&gt;vid = 1; // ‘1’ is a vocabulary id you wish this term to assign to
$term-&gt;field_custom_field_name[LANGUAGE_NONE][0]['value'] = ‘Some value’; // OPTIONAL. If your term has a custom field attached it can added as simple as this
taxonomy_term_save($term); // Finally, save our term


From Link

I don't know where to write it. I think it will be in template.php with some hook ? 

Drupal 7
If you just want to run an arbitrary PHP script through Drupal, the easiest way is probably using the Devel module

It provides a page (/devel/php) where you can copy/paste PHP code and have it run inside a fully bootstrapped instance of Drupal.