topical media & game development

talk show tell print

server-amf-json-service.php / php



  <?php
  
  
service: get person / get manager

person


  
  class Person
  {
          public first_name;
          public last_name;
          public email;
          public address;
  }
  
  

manager


  
  class Manager extends Person
  {
          public title;
          public employees;
  }
  
  

getPerson


  
  if(isset(_GET['getPerson']))
  {
          p = new Person();
          p->first_name = 'John';
          p->last_name = 'Doe';
          p->email = 'fake@email.com';
          p->address = '5555 Some Street City, State 55555';
          echo json_encode(p);
  }
  
  

getmanager


  
  if(isset(_GET['getManager']))
  {
          p1 = new Person();
          p1->first_name = 'Joe';
          p1->last_name = 'Doe';
          p1->email = 'joe.doe@email.com';
          p1->address = '5424 Some Street City, State 55555';
          p2 = new Person();
          p2->first_name = 'Bob';
          p2->last_name = 'Doe';
          p2->email = 'bob.doe@email.com';
          p2->address = '1414 Some Street City, State 55555';
          p3 = new Person();
          p3->first_name = 'Kevin';
          p3->last_name = 'Doe';
          p3->email = 'kevin.doe@email.com';
          p3->address = '6123 Some Street City, State 55555';        
          m = new Manager();
          m->first_name = 'Manager';
          m->last_name = 'Doe';
          m->email = 'manager.doe@email.com';
          m->address = '5534 Some Other Street City, State 55555';
          m->title = 'Office Manager';
          m->employees = array(p1, p2, p3);
          echo json_encode(m);
  }
  ?>
  


(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.