$subject = new Subject("Math"); $marcus = new Teacher("Marcus Brasizza"); $rafael = new Student("Rafael"); $vinicius = new Student("Vinicius"); // Include observers in the math Subject $subject->attach($rafael); $subject->attach($vinicius); $subject->attach($marcus); $subject2 = new Subject("English"); $renato = new Teacher("Renato"); $fabio = new Student("Fabio"); $tiago = new Student("tiago"); // Include observers in the english Subject $subject2->attach($renato); $subject2->attach($vinicius); $subject2->attach($fabio); $subject2->attach($tiago); // Remove the instance "Rafael from subject" $subject->detach($rafael); // Notify both subjects $subject->notify(); $subject2->notify(); echo"First Subject <br />"; echo"<pre>"; print_r($subject->GET_log()); echo"</pre>"; echo"<hr>"; echo"Second Subject <br />"; echo"<pre>"; print_r($subject2->GET_log()); echo"</pre>";
[0] => Subject Math was included [1] => The Student Rafael was included [2] => The Student Vinicius was included [3] => The Teacher Marcus Brasizza was included [4] => The Student Rafael was removed [5] => Comes from Vinicius: I'm a student of Math [6] => Comes from Marcus Brasizza: I teach in Math ) //Second Subject Array ( [0] => Subject English was included [1] => The Teacher Renato was included [2] => The Student Vinicius was included [3] => The Student Fabio was included [4] => The Student tiago was included [5] => Comes from Renato: I teach in English [6] => Comes from Vinicius: I'm a student of English [7] => Comes from Fabio: I'm a student of English [8] => Comes from tiago: I'm a student of English )
[0] => Subject Math was included [1] => The Student Rafael was included [2] => The Student Vinicius was included [3] => The Teacher Marcus Brasizza was included [4] => The Student Rafael was removed [5] => Comes from Vinicius: I'm a student of Math [6] => Comes from Marcus Brasizza: I teach in Math )