Change default favicon programmatically
You can place the favicon.ico in your theme folder (at the same level as your_theme.info) and it will be used automatically.

Works for Drupal 6, 7 &amp; 8.

Note: The favicon is heavily cached by some browsers, you may need to go to extra lengths to see the new one.