Whats the best way to create links to dish out to partner websites so they get a commission from the clickthrough they generate?
I would prefer a PHP solution if there is one available?
An easy way to get started with an affiliate program is to use an affiliate network they have everything all setup for you as well as a bunch of affiliates you can promote your program to.
If you're looking to set up your own, it usually works by placing an affiliate ID in the link you give them (IE example.com?id=affiliate1) then when someone visits your site from that link you drop a cookie that says this user is from affiliate1.
If you are using an open source CMS some of them have affiliate tracking as a built in option or plugin, and there seem to be many options available if you run a Google search for "open source affiliate software" (haven't used any of these myself though).