Chapter 9. Other Extensions

This chapter covers three new parts of PHP 5: the SOAP and Tidy extensions and the Reflection classes.

SOAP is an XML-based protocol for exchanging information over the Internet that you can use to build or utilize web services. The SOAP extension provides you with an easy way to both query SOAP servers and implement a SOAP server of your own.

The Tidy extension tackles the problem of invalid HTML. It converts malformed web pages into fully valid HTML and XHTML. Tidy also lets you optimize your web pages by removing unnecessary characters. This translates into faster download times and lower bandwidth bills, a double advantage. Finally, Tidy helps you out when you’re in the unfortunate position of parsing HTML to extract data, such as when you’re screen-scraping.

With the Reflection classes, you can programmatically extract information about classes, functions, methods, and properties. This allows you to produce automated class documentation, write a PHP debugger, and other tasks that require object introspection.

SOAP

Web services allow you to exchange information over HTTP using XML. When you want to find out the weather forecast for New York City, the current stock price of IBM, or the best-selling DVD according to Amazon.com, you can write a short script to gather that data in a format you can easily manipulate. From a developer’s perspective, it’s as if you’re calling a local function that returns a value.

A major advantage of web services is ubiquity ...

Get Upgrading to PHP 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.