Bonjour,
si j'appelle la méthode en direct, elle marche mais pas si j'utilise un formulaire pour l'appeler. Mon code rendra les choses claires.
La méthode (de la classe Ticket) :
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 public function test(){ ?> <form action="" method="POST"> <input type="submit" name="submit1" value="test form"><br/> </form> <?php if (isset($_POST['submit1'])) $this->mouchard=TRUE; else $this->mouchard=FALSE; } //end method test()
Le code qui marche :
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 $tic=new Ticket(); $tic->test(); var_dump($tic->mouchard);
Le code qui marche pas (dans ce cas, je sélectionne test et la ligne 26 est bien appelée (j'ai vérifié)) :
Quand ça marche, $tic->mouchard vaut TRUE et quand ça marche pas, FALSE. Pourquoi ? J'ai beau chercher, je comprends pas.
Code php : 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 $tic=new Ticket(); $meth=['Clean_Dbb','Csv_To_Db', 'test', 'product name']; ?> <html> <body> <form method="post" action="" onchange="submit();"> <select name="meth" id=""> <option value="0">list of methods</option> <?php foreach($meth as $met) { echo "<option value='".$met."'>".$met."</option>"; } ?> </select> </form> </body> </html> <?php if (isset($_POST['meth'])) { if ($_POST['meth']!="0") { switch($_POST['meth']) { case 'Clean_Dbb' : {$tic->Clean_Dbb(); break;} case 'Csv_To_Db' : {$tic->Csv_To_Db(); break;} case 'test' : {$tic->test(); break;} case 'product name' : {$pn=$tic->Get_Product_Name(); break;} default : {$tic->mouchard=2; break;} } } } var_dump($tic->mouchard);
Partager