Well, it depends what you mean. I mean, when you click the link to the 'coding' forum here, it runs a PHP function. But that sounds too simple so its probably not what you mean.
It sounds like you want the link to lead to one place, and the PHP function to be run on the side. You could try making the link lead to the PHP script first, then redirect the person to the new place, or you could simply put the PHP function in the script that the link leads to if applicable.