I've seen a few PHP examples floating around that connected to CRM Online but I'm not sure I've ever seen any that will also connect to an On Premise IFD organization. This is basically a port of the C# version that I previously posted to PHP. Prior to this I've never done any PHP development so if the code is terrible - sorry. Hopefully though it gives anyone doing PHP development a starting point for connecting directly to Dynamics CRM without having a .NET middle tier in place to facilitate the exchange.
I've created a sample application that authenticates to CRM and returns the logged in user's name.
The code to create the SOAP headers looks like this: