topical media & game development

talk show tell print

professional-php-05-factoryTest.php / php



  <?php
  studentID = 1; //use a valid studentid value from your student table
  
  try {
    objStudent = StudentFactory::getStudent(studentID);  
  } catch (Exception e) {
    die("Student #studentID doesn't exist in the database!");
  }
  
  print objStudent . 
        (objStudent->courses->exists('CS101') ? ' is ' : ' is not ') .
        'currently enrolled in CS101';
  //displays: "Bob Smith is enrolled in CS101"
  ?>
  


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