Incrémentation d'une variable de classe
Bonjour à tous.
Je suis en train de développer un formulaire en POO, mais je n'arrive pas à incrémenter ma variable de classe qui me permettra de différencier les variables de mes formulaires.
Je m'explique :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| class Formulaire
{
private $gauche = 'gauche';
private $nomformulaire = 'formulaire';
private $submitdelai = 'submit_del';
private $submitactivite = 'submit_act';
private $from = 'from';
private $to = 'to';
private $horaireA = 'horaireA';
private $horaireB = 'horaireB';
private $jours = 'jours';
private $ferie = 'ferie';
private $labo = 'labo';
private $corres = 'corres';
private static $numform = 0;
public function __construct()
{
$numform++;
$this->gauche = $this->gauche.$numform;
$this->nomformulaire = $this->nomformulaire.$numform;
$this->from = $this->from.$numform;
$this->to = $this->to.$numform;
$this->submitdelai = $this->submitdelai.$numform;
$this->submitactivite = $this->submitactivite.$numform;
$this->horaireA = $this->horaireA.$numform;
$this->horaireB = $this->horaireB.$numform;
$this->jours = $this->jours.$numform;
$this->ferie = $this->ferie.$numform;
$this->labo = $this->labo.$numform;
$this->corres = $this->corres.$numform; |
En gros je cherche à incrémenter mon $numform à chaque nouvelle instantiation. Ensuite chacune de mes variables sera différentiée par la concaténation de ce numform avec leur nom.
Exemple : Obj1 = gauche1, horaireA1, labo1...
Obj2 = gauche2, horaireA2,labo2...
Merci de votre aide.