Exemplo n.º 1
0
 /**
  *
  * @param boolean $wrap
  */
 public function getResult($wrap)
 {
     $rc = $this->factory->getProxy($this->val, $this->signature, $this->exception, $wrap);
     $factory = $this->factory;
     $this->factory = $this->client->simpleFactory;
     $factory->checkResult($rc);
     return $rc;
 }
Exemplo n.º 2
0
 function main()
 {
     // 如果不用工厂模式,则需要提前指定具体类
     // $person = new Teacher();
     // echo $person->getName();
     // $person = new Student();
     // echo $person->getName();
     // 用工厂模式,则不需要知道对象由什么类产生,交给工厂去决定
     $person = SimpleFactory::getPerson('teacher');
     echo $person->getName();
     $person = SimpleFactory::getPerson('student');
     echo $person->getName();
 }