On a default Drupal installation without any template customizations they will output the same thing.
However, the theme()
function is essentially a wrapper for the theming system in Drupal. By passing 'links' as the first parameter, you are telling Drupal to look for the links theme whether this be a function or a template. In this case the theme is a function (theme_links()
) which gets called.
If you would want to make changes to the theme, you could do so by overriding it. For example you could create the function myTheme_links()
and have it override the default theme_links()
. If you are calling the function theme_links()
directly, you would have to change this code to the appropriate theme function. However, if you used the theme()
function, there wouldn't be any additional change since this function knows when themes are overridden and takes the appropriate action. In a nutshell, using the theme()
function is the more flexible solution for future proofing your code and probably considered the Drupal way of doing things.
For more information on theming, check out Drupal's theme documentation.