<?php class getpost{ public $get = array(); public $post = array(); function getpost(){ if(isset($_GET)){ $this->get(); } if(isset($_POST)){ $this->post(); } } function get(){ $dizi = array_keys($_GET); if(count($dizi)!=0){ for($n=0;$n<count($dizi);$n++){ $this->get[$dizi[$n]] = $_GET[$dizi[$n]]; } }else{ $this->get = NULL; } } function post(){ $dizi = array_keys($_POST); if(count($dizi)!=0){ for($n=0;$n<count($dizi);$n++){ $this->post[$dizi[$n]] = $_POST[$dizi[$n]]; } }else{ $this->post = NULL; } } } $a = new getpost(); if($a->get){ echo "<pre>"; print_r($a->post); echo "<br>"; print_r($a->get); }else{ ?><form name="form1" method="post" action="?get=1"> <label> <input type="text" name="post"> </label> <br> <input type="text" name="post2"> <br> <input type="text" name="post3"> <br> <input type="text" name="post4"> <br> <input type="text" name="post5"> <br> <input type="text" name="post6"> <br> <label> <input type="submit" name="gonder" value="GÖNDER"> </label> </form> <?php } ?>
Çıktısı
Array ( [post] => yazı1 [post2] => yazı2 [post3] => yazı3 [post4] => yazı4 [post5] => yazı5 [post6] => yazı6 [gonder] => GÖNDER ) Array ( [get] => 1 )