<?PHP class formyap { function yeniform( $method, $action ) { $metin = "<form method=\"".$method."\" action=\"".$action."\">"; return($metin); } function formubitir() { $metin = "</form>"; return($metin); } function metin( $ad ) { $metin = "<input type=\"metin\" ad=\"".$ad."\">"; return($metin); } function pass( $ad ) { $metin = "<input type=\"password\" ad=\"".$ad."\">"; return($metin); } function radio( $ad, $bilgi ) { $metin=null; foreach($bilgi as $deger) { $metin.=$deger." <input type=\"radio\" ad=\"".$ad."\" deger=\"". $deger ."\"></input>"; } return($metin); } function checkbox( $bilgi ) { $metin=null; foreach( $bilgi as $anahtar=>$deger) { $metin.=$deger." <input type=\"checkbox\" ad=\"".$anahtar."\" deger=\"". $deger ."\"></input>"; } return($metin); } function select( $ad, $bilgi, $boyut ) { $metin = "<SELECT NAME=\"".$ad."\" size=".$boyut.">"; foreach( $bilgi as $deger ) { $metin.="<OPTION>".$deger; } $metin = $metin."</SELECT>"; return($metin); } function kombo( $ad, $bilgi ) { $metin = "<SELECT NAME=\"".$ad."\">"; foreach( $bilgi as $deger ) { $metin.="<OPTION>".$deger; } $metin = $metin."</SELECT>"; return($metin); } function metinarea( $ad, $satir, $sutun ) { $metin = "<TEXTAREA NAME=\"".$ad."\" ROWS=".$satir." COLS=".$sutun."></TEXTAREA>"; return($metin); } function submit( $ad, $deger ) { $metin = "<INPUT TYPE=submit NAME=\"".$ad."\"VALUE=\"".$deger."\"></INPUT>"; return($metin); } function fclear( $ad ) { $metin = "<INPUT TYPE=reset VALUE=\"".$ad."\"></INPUT>"; return($metin); } } $frm = new formyap(); echo $frm->yeniform( "POST", "index.php" ); echo $frm->metin("testing"); echo $frm->pass("testing"); echo $frm->radio( "test", array("v1", "v2", "v3", "v4")); echo $frm->checkbox(array("test1"=>"v1", "test2"=>"v2", "test3"=>"v3", "test4"=>"v4")); echo $frm->select( "test", array("v1", "v2", "v3", "v4"), 4); echo $frm->kombo( "test", array("v1", "v2", "v3", "v4")); echo $frm->metinarea( "testing", 6, 60 ); echo $frm->submit("submit", "Gönder"); echo $frm->fclear( "Sıfırla" ); echo $frm->formubitir(); ?>
Çıktı
<form method="POST" action="index.php"> <input type="text" name="testing"><input type="password" name="testing">v1 <input type="radio" name="test" value="v1"></input>v2 <input type="radio" name="test" value="v2"></input>v3 <input type="radio" name="test" value="v3"></input>v4 <input type="radio" name="test" value="v4"></input>v1 <input type="checkbox" name="test1" value="v1"></input>v2 <input type="checkbox" name="test2" value="v2"></input>v3 <input type="checkbox" name="test3" value="v3"></input>v4 <input type="checkbox" name="test4" value="v4"></input> <SELECT NAME="test" size=4> <OPTION>v1 <OPTION>v2 <OPTION>v3 <OPTION>v4 </SELECT> <SELECT NAME="test"> <OPTION>v1 <OPTION>v2 <OPTION>v3 <OPTION>v4 </SELECT> <TEXTAREA NAME="testing" ROWS=6 COLS=60></TEXTAREA> <INPUT TYPE=submit NAME="submiter"VALUE="Submit Me!"></INPUT><INPUT TYPE=reset VALUE="Reset Form"></INPUT> </form>