[POO] Code non fonctionnel
Bonjour, je commence à faire du php orienté objet et je voulais savoir si il y a une configuration speciale à faire car j'ai un code qui a l'aire bon mais rien ne s'affiche^^
Bon si le probleme vient du code le voici:
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 32 33
| <?php
class AdresseMail{
public $Mail;
public function SetMail($mail) {
$this->Mail = $mail;
}
public function IsValide(){
$verif="!^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]{2,}\.[a-zA-Z]{2,4}$!";
if(!preg_match($verif,$this->Mail)){ // verification du mail
return false;
}
return true;
}
public function AfficherMail(){
echo $this->Mail;
}
}
$a = new AdresseMail();
$a->SetMail("lab@ici.la");
$b = new AdresseMail();
$b->SetMail("n'importe quoi");
$a->AfficherMail();
$b->AfficherMail();
if($a->IsValid()) $a->AfficherMail();
if($b->IsValid()) $b->AfficherMail();
?> |
Merci de votre aide :)