Bonjour
Je ne comprend pas pourquoi j'ai cette erreur : "Fatal error: Call to undefined method Personne:ersonne() in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\TpPHP\Patient.php on line 11"
Voici ma classe Personne.php
Voici ma classe Patient.php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
34
35
36
37
38
39
40
41
42
43
44
45 <?php class Personne{ private $_nom; private $adresse; private $_tel; private $_age; public function __construct($no, $ad, $te, $ag){ $this->_nom=$no; $this->_adresse=$ad; $this->_tel=$te; $this->_age=$ag; } public function getNom(){ return $this->_nom; } public function setNom($no){ $this->_nom = $no; } public function getAdresse(){ return $this->_adresse; } public function setAdresse($ad){ $this->_adresse = $ad; } public function getTel(){ return $this->_tel; } public function setTel($te){ $this->_tel = $te; } public function getAge(){ return $this->_age; } public function setAge($age){ $this->_age = $ag; } }
Et voici mon fichier testPersonne.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <?php require_once("Personne.php"); class Patient extends Personne // Présence du mot-clé class suivi du nom de la classe. { private $_numsecu; public function __construct($no, $ad, $te, $ag, $num){ //Appel du constructeur parent parent::Personne($no, $ad, $te, $ag); $this->_numsecu=$num; } public function getNumsecu(){ return $this->_numsecu; } public function setNumsecu($num){ $this->_numsecu = $num; } } ?>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php require_once("Personne.php"); require_once("Patient.php"); $superman = new Personne("Anouchka", "Yvetot", "0658898531", "30 ans"); $patient = new Patient("Laurence", "Yvetot", "0658898531", "30 ans", "125896347852145"); /* echo $superman->getNom().'<br/>'; echo $superman->getAdresse().'<br/>'; echo $superman->getTel().'<br/>'; echo $superman->getAge() .'<br/> <hr>'; */ echo $patient->getNom().'<br/>'; echo $patient->getAdresse().'<br/>'; echo $patient->getTel().'<br/>'; echo $patient->getAge() .'<br/>'; echo $patient->getNumsecu() .'<br/> <hr>';
Partager