-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfinal.php
More file actions
30 lines (30 loc) · 852 Bytes
/
final.php
File metadata and controls
30 lines (30 loc) · 852 Bytes
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
<?php
//================================================================================
//si on fait preceder la class par le mot final, elle sera non heritable
class Personnage{
protected $nom;
protected $origine;
protected function __construct($n,$o){
$this->nom=$n;
$this->origine=$o;
}
//impossible de redefinir cette methode
final function affiche(){
echo $this->nom;
}
}
//====================================================================================
class Enfant extends Personnage{
private $taille;
public function __construct($n,$o,$t){
parent::__construct($n,$o);
$this->taille=$t;
}
public function affiche_info(){
$this::affiche();
echo '<br/>'.$this->taille;
}
}
$enf=new Enfant('Junior','Zambi',165);
$enf->affiche_info();
?>