[POO] Première classe PHP5
Bonjour à tous,
Je me suis enfin faite une première classe, sans intérêt aucun mais j'aurais aimé avoir vos avis sur la façon dont elle est construite :)
Il s'agit simplement d'une classe qui génère un bouton radio
La classe
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| class create_radio{
public $name;
public $type;
private $champ;
public $value;
function create_radio($name,$type,$label,$value){
$this->name=$name;
$this->type=$type;
$this->value=$value;
$this->label=$label;
}
function affiche(){
$this->champ='<label for="'.$this->label.'">'.$this->label.'</label><input type="'.$this->type.'" name="'.$this->name.'" value="'.$this->value.'">';
return $this->champ;
}
} |
Et l'instanciation
Code:
1 2
| $champ2=new create_radio("test","radio","Oui","oui");
echo $champ2->affiche(); |
Voila, ça marche, mais après je ne sais pas si je pratique bien
Merci d'avance,
edit > utilisation d'un constructeur maintenant ^^