topical media & game development

talk show tell print

professional-ria-04-helloResponsev2.php / php



  <?php
  /*
  Second version of helloResponse.php.
     
  This version includes:
    - lookupMessage enhanced to provide an XML formatted response.
  */
  
    header('Content-Type: text/xml');
  
    function lookupMessage(mCountry) 
    {
        if (mCountry == "France")
          return 'Bonjour Monde!';
        else if (mCountry == "Germany")
          return 'Hallo Welt!';
        else if (mCountry == "Spain") 
          return 'Hola Mundo!';
        else if (mCountry == "USA") 
          return 'Hello World!';
        else 
          return 'Unknown Message!';
    }
  
    function lookupSender(mCountry) 
    {
        if (mCountry == "France")
          return 'Dana';
        else if (mCountry == "Germany")
          return 'Ray';
        else if (mCountry == "Spain") 
          return 'Ted';
        else if (mCountry == "USA") 
          return 'Jonathan';
        else 
          return 'Unknown Sender!';
    }
  ?>
  <?xml version="1.0" encoding="UTF-8"?>
  <response>
    <sender><?php echo lookupSender(_GET['country'])?></sender>
    <message><?php echo lookupMessage(_GET['country'])?></message>
  </response>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.