Menü ve Alt Menü Oluşturma Sınıfları

<?php
class altmenu {
  var $adresler;
  var $isim;
  var $dizi;
  var $id;
  function olustur($id){
    $this->dizi=0; 
		$this->id=$id;
  }
  function ekle($url, $desp){
    $this->adresler[$this->dizi]=$url;
    $this->isim[$this->dizi]=$desp;	
    $this->dizi++;
  }
  function acik(){
		$i=0;
		echo '<table width="15%" border="0" align="center">';
		while($i<=$this->dizi-1) {
			if ($i==0){
				echo '<tr><th align="center" bgcolor="#34ABC0"><font color="White">';
				echo $this->isim[0];
				echo '</font></th></tr>';
			}else{
				echo '<tr><td align="center"><font size="-1">';
				echo '<a href="'.$this->adresler[$i].'">'.$this->isim[$i].'</a>';
				echo '</font></td></tr>';
			}
			$i++;
		}
		echo '</table>';
  }
  function kapat(){
    echo '<table width="15%" border="0" align="center">';
    echo '<tr><th align="center" bgcolor="#34ABC0"><font color="White">';
    echo '<a href="?durum=acik&id='.$this->id.'">'.$this->isim[0].'</a>';
		echo '</font></th></tr>';  
    echo '</table>';	
  }
}
class menu{
  var $altmenuler;
  var $dizi;
  var $id;
  function olustur(){
    $this->dizi=0;
		$this->id=2;
  }
  function ekle($altmenu){
    $this->altmenuler[$this->dizi]=new altmenu;
		$this->altmenuler[$this->dizi]=$altmenu;
		$this->dizi++;
  }
  function goster(){
    $i=0;
		$gec = new altmenu;
		while ($i<$this->dizi) {
			$gec=$this->altmenuler[$i];
			if ($gec->id==(string)$this->id) {
				$gec->acik();
			}else{
				$gec->kapat();
			}
			$i++;
		}
  }
}
$mm_1=new altmenu;
$mm_1->olustur('1');
$mm_1->ekle('','Menü1');
$mm_1->ekle('#site=1','Alt Menü1');
$mm_1->ekle('#site=2','Alt Menü2');
$mm_1->ekle('#site=3','Alt Menü3');
$mm_1->ekle('#site=4','Alt Menü4'); 
$mm_2=new altmenu;
$mm_2->olustur('2');
$mm_2->ekle('','Menü2');
$mm_2->ekle('#site=5','Alt Menü1');
$mm_2->ekle('#site=6','Alt Menü2');
$mm_2->ekle('#site=7','Alt Menü3');
$mm_2->ekle('#site=8','Alt Menü4');
$mm_3=new altmenu;
$mm_3->olustur('3');
$mm_3->ekle('','Menü3');
$mm_3->ekle('#site=9','Alt Menü1');
$mm_3->ekle('#site=10','Alt Menü2');
$mm_3->ekle('#site=11','Alt Menü3');
$mm_3->ekle('#site=12','Alt Menü4');
$mm_4=new altmenu;
$mm_4->olustur('4');
$mm_4->ekle('','Menü4');
$mm_4->ekle('#site=13','Alt Menü1');
$mm_4->ekle('#site=14','Alt Menü2');
$mm_4->ekle('#site=15','Alt Menü3');
$mm_4->ekle('#site=16','Alt Menü4');
$m_1=new menu;
$m_1->olustur();
$m_1->ekle($mm_1);
$m_1->ekle($mm_2);
$m_1->ekle($mm_3);
$m_1->ekle($mm_4);
extract($_GET);
if(!isset($durum)){
  $m_1->goster();
}else{
	if ($durum=='acik') {
		$m_1->id=$id;
		$m_1->goster();
	}else{
		$m_1->goster();
	}
}
?>

Çıktısı

<table width="15%" border="0" align="center">
   <tr>
      <th align="center" bgcolor="#34ABC0"><font color="White"><a href="?durum=acik&id=1">Menü1</a></font></th>
   </tr>
</table>
<table width="15%" border="0" align="center">
   <tr>
      <th align="center" bgcolor="#34ABC0"><font color="White">Menü2</font></th>
   </tr>
   <tr>
      <td align="center" ><font size="-1"><a href="#site=5">Alt Menü1</a></font></td>
   </tr>
   <tr>
      <td align="center" ><font size="-1"><a href="#site=6">Alt Menü2</a></font></td>
   </tr>
   <tr>
      <td align="center" ><font size="-1"><a href="#site=7">Alt Menü3</a></font></td>
   </tr>
   <tr>
      <td align="center" ><font size="-1"><a href="#site=8">Alt Menü4</a></font></td>
   </tr>
</table>
<table width="15%" border="0" align="center">
   <tr>
      <th align="center" bgcolor="#34ABC0"><font color="White"><a href="?durum=acik&id=3">Menü3</a></font></th>
   </tr>
</table>
<table width="15%" border="0" align="center">
   <tr>
      <th align="center" bgcolor="#34ABC0"><font color="White"><a href="?durum=acik&id=4">Menü4</a></font></th>
   </tr>
</table>