Getting NuSOAP to work in PHP5

I’ve been playing with NuSOAP (a SOAP toolkit for PHP) and had trouble getting it working under PHP5. I was getting the following error:

Fatal error: Cannot redeclare class soapclient in C:\Program Files\xampp\htdocs\dev\lib\nusoap.php on line 7240

It turns out that PHP5’s own SOAP extension uses soapclient as a class name. The easy solution is to replace all instances of soapclient in the NuSOAP library files (and your own code) with something else – I chose nusoapclient. If you use Notepad++, it’s as simple as opening all 13 source files and running a search/replace.

If you enjoyed this post, please share it!