05/02_kompoziciaX1.php


  1  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
  2  <html>
  3  <head>
  4    <meta http-equiv="Author" content="Imrich BURANSKY" />
  5    <meta http-equiv="Content-Type" content="text/html; charset=Windows-1250" />
  6    <title>KompozíciaX1</title>
  7  </head>
  8  <body>
  9  <div>
 10  <h2>Kompozícia</h2>
 11  <?php
 12  
 13  class CA
 14  {
 15    public function __construct()
 16    {
 17      echo "CA: Konštruktor<br />\n";
 18    }
 19  
 20    public function FA ()
 21    {
 22      echo "CA: Funkcia FA<br />\n";
 23    }
 24  }
 25  
 26  class CB
 27  {
 28    public $A;
 29    public function __construct($A)
 30    {
 31      echo "CB: Konštruktor<br />\n";
 32      $this->A = $A;
 33    }
 34  
 35    public function FB ()
 36    {
 37      echo "CB: Funkcia FB<br />\n";
 38    }
 39  
 40    public function FX ()
 41    {
 42      echo "CB: Funkcia FX<br />\n";
 43      $this->A->FA();
 44    }
 45  }
 46  echo "<b>Vytvorenie a použitie objektu triedy CB</b><br />\n";
 47  $B = new CB(77); // CB: Konštruktor
 48  $B->FB();        // CB: Funkcia FB
 49  
 50  ?>
 51  </div>
 52  </body>
 53  </html>

« Späť