How to create a basic PHP-based web service

I borrowed from this page ( information on how to create a basic PHP web-service. See the attached/modified version. Simply rename the .txt to .php, then place the attached file in an apache accessible directory and call the page with URL params, like so: http://sv-selenium-t1/service/service.php?id=2&format=xml.