Bonjour,

Je ne suis pas un expert en php mais j'ai les bases. J'ai crée une class utilisateur que j'instancie dans ma page 1 : login.php. Cette page est inclue avec d'autre page dans ma page d'index. Dans les pages que j'inclus il y a mon menu et dans ce menu j'aimerai appeler un fonction de ma class utilisateur qui est getNomComplet() sauf que cela fonctionne pas et je ne comprends pas pourquoi ? et comme les variables objet fonctionne.

utilisateur.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
 
<?php
class Utilisateur{
    private $_nom;
    private $_prenom;
    private $_adresse;
    private $_civilite;
    private $_mail;
    private $_numTel;
    private $_ticSEM;
    private $_ticWE;
    private $_parcours;
    private $_annulation;
    private $_invitation;
    private $_argent;
    private $_role;
 
    public function __construct($_nom, $_prenom, $_adresse, $_civilite, $_mail, $_numTel, $_ticSEM, $_ticWE, $_parcours, $_annulation, $_invitation, $_argent, $_role){
        $this->_nom = $_nom;
        $this->_prenom = $_prenom;
        $this->_adresse = $_adresse;
        $this->_civilite = $_civilite;
        $this->_mail = $_mail;
        $this->_numTel = $_numTel;
        $this->_ticSEM = $_ticSEM;
        $this->_ticWE = $_ticWE;
        $this->_parcours = $_parcours;
        $this->_annulation = $_annulation;
        $this->_invitation = $_invitation;
        $this->_argent = $_argent;
        $this->_role = $_role;
    }
 
    public function getNomComplet(){
        if($this->_civilite == 'M'){
            return "Mr." + $this->_nom + " " + $this->_prenom + " | " + $this->_role;
        } else {
            return "Mr." + $this->_nom + " " + $this->_prenom + " | " + $this->_role;
        }
    }
 
    public function ajouterTicSEM($_quantite){
        $this->_ticSEM+=$_quantite;
    }
 
    public function ajouterTicWE($_quantite){
        $this->_ticSEM+=$_quantite;
    }
 
    public function setNom($_nom){
       $this->_nom=$_nom;
    }
 
    public function getNom(){
        return $this->_nom;
    }
 
    public function setPrenom($_prenom){
        $this->_prenom=$_prenom;
    }
 
    public function getPrenom(){
        return $this->_prenom;
    }
 
    public function setAdresse($_adresse){
        $this->_adresse=$_adresse;
    }
 
    public function getAdresse(){
        return $this->_adresse;
    }
 
    public function setEmail($_email){
        $this->_mail=$_email;
    }
 
    public function getNumTel()
    {
        return $this->_numTel;
    }
 
    public function getTicSEM()
    {
        return $this->_ticSEM;
    }
 
    public function getTicWE()
    {
        return $this->_ticWE;
    }
 
    public function getParcours()
    {
        return $this->_parcours;
    }
 
    public function getAnnulation()
    {
        return $this->_annulation;
    }
 
    public function getInvitation()
    {
        return $this->_invitation;
    }
 
    public function getArgent()
    {
        return $this->_argent;
    }
 
    public function setNumTel($_numTel)
    {
        $this->_numTel = $_numTel;
    }
 
    public function setTicSEM($_ticSEM)
    {
        $this->_ticSEM = $_ticSEM;
    }
 
    public function setTicWE($_ticWE)
    {
        $this->_ticWE = $_ticWE;
    }
 
    public function setParcours($_parcours)
    {
        $this->_parcours = $_parcours;
    }
 
    public function setAnnulation($_annulation)
    {
        $this->_annulation = $_annulation;
    }
 
    public function setInvitation($_invitation)
    {
        $this->_invitation = $_invitation;
    }
 
    public function setArgent($_argent)
    {
        $this->_argent = $_argent;
    }
 
}
?>
login.php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
 require_once 'utilisateur.php';
 require_once 'role.php';
 $test = new Utilisateur($RESULT['Nom'], $RESULT['Prenom'], $RESULT['Adresse'], $RESULT['Civilité'], $RESULT['Mail'], $RESULT['NumTel'], $RESULT['TicketSEM'], $RESULT['TicketWE'], $RESULT['Parcours'], $RESULT['Annulation'], $RESULT['Invitation'], $RESULT['Argent'], getRole($RESULT['Pseudo']));
mon menu :
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
 
<div class="topnav" id="myTopnav">
	<a href="index.php" class="actives"><i class="fas fa-home"></i> Accueil</a>
	<?php 
    	if(isConnected()){
    	   echo "<a href='./calendrier.php'> Calendrier</a>"; 
    	   echo "<a href='./logout.php' id='Connexion'><i class='fas fa-power-off' style='font-size: 25px;'></i></a>";
    	   echo "<a href=''> Option</a>";
           echo $test->getgetNomComplet();
    	} else {
    	    echo "<a href='./calendrier.php' id='Connexion'><i class='fas fa-user'></i> Connexion</a>";
    	}
	?>
  	<a href="javascript:void(0);" class="icon" onclick="myFunction()"><i class="fas fa-bars" style="font-size: 25px"></i></a>
</div>
J'ai l'erreur : Notice: Undefined variable: test in /Applications/MAMP/htdocs/Test/public/view/menu.php on line 8 comme quoi ma variable n'est pas défini alors que elle est défini dans mon login et dans ma page je l'inclus donc je comprends pas trop

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
<?php 
    include("./private/BDD/login.php");
    check_Login();
?>
<html>
	<?php include("./public/view/head.php"); ?>
	<body>
		<?php include("./public/view/header.php"); ?>
		<?php include("./public/view/menu.php"); ?>
	</body>
</html>
si une personne peut m'aider ? merci