text: <html>
  <head>
  <title>045.php</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <script>
  function navigate(e) {
      var keynum = (window.event) // IE
          ? e.keyCode
          : e.which;
      if (keynum == 8) {
          window.location = "044" + ".html";
          return false;
      }
      if (keynum == 13 || keynum == 32) {
          window.location = "046" + ".html";
          return false;
      }
      if (keynum == 73 || keynum == 105) {
          window.location = "index.html";
          return false;
      }
      return true;
  }
  </script>
  </head>
  <body onkeypress="return navigate(event)">
  <pre>                                                                     SplObjectStorage #3
    
    &lt;?php
    
    $obj1 = new StdClass;
    $obj1-&gt;name = 'Thrall';
    $obj2 = new StdClass;
    $obj2-&gt;name = 'Sylvanas';
    $obj3 = new StdClass;
    $obj3-&gt;name = 'Cairne';
    $obj4 = new StdClass;
    $obj4-&gt;name = 'Voljin';
    
    $sos = new SplObjectStorage();
    
    $sos-&gt;attach($obj1, 'Orc');
    $sos-&gt;attach($obj2, 'Undead');
    $sos-&gt;attach($obj3, 'Tauren');
    $sos-&gt;attach($obj4, 'Troll');
    
    foreach ($sos as $obj) {
        echo $obj-&gt;name, &quot; - &quot;, $sos-&gt;getInfo(), &quot;\n&quot;;
    }
    
    echo &quot;--\n&quot;;
    
    $sos-&gt;detach($obj3);                    // 케른 블러드후프 사망
    foreach ($sos as $obj) {
        if ($obj == $obj2) {
            $sos-&gt;setInfo('Blood Elf');     // 실바나스는 블엘로
        }
    }
    
    foreach ($sos as $obj) {
        echo $obj-&gt;name, &quot; - &quot;, $sos-&gt;getInfo(), &quot;\n&quot;;
    }
    
    ?&gt;
  </pre>
  </body>
  