Bonjour a tous !
je me met avec php 5 et ne trouve pas dans la fac comment faire accepter a PHP un constructeur surchargé, mon code est :
mon appel est :
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 /**function experience(){ experience('id','categorie','societe','ville','dept','pays','titre','soustitre','logo','typcontrat','datedeb','datefin','resume','technique','tool','detail','credate'); }**/ //constructeur surcharge function experience($expid,$cat,$soc,$ville,$dept, $pays,$titre,$soustitre,$logo,$typcontrat,$datedeb, $datefin,$resume,$tech,$tool,$detail,$credate){ $newexp->expid = $this->setExpId($expid); $newexp->cat = $this->setCat($cat); $newexp->soc = $this->setSoc($soc); $newexp->ville = $this->setVille($ville); $newexp->dept = $this->setDept($dept); $newexp->pays = $this->setPays($pays); $newexp->titre = $this->setTitre($titre); $newexp->soustitre = $this->setSousTitre($soustitre); $newexp->logo = $this->setLogo($logo); $newexp->typcontrat = $this->setTypContrat($typcontrat); $newexp->datedeb = $this->setDateDeb($datedeb); $newexp->datefin = $this->setDateFin($datefin); $newexp->resume = $this->setResume($resume); $newexp->tech = $this->setTech($tech); $newexp->tool = $this->setTool($tool); $newexp->detail = $this->setDetail($detail); $newexp->credate = $this->setCreDateExp($credate); //echo 'test : newuser est cré'; //DEBUG ONLY return $newexp; }
le premier constructeur (vide) est en commentaire a cause du message d'erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 include('class/experience.php'); /**echo ("test de l'objet experience<br /><br />"); $exp = new experience(); $exp->displayExp();**/ echo ("<br /><br />test de l'objet experience surchargée<br /><br />"); $exp2 = new experience(1,'macategorie','masociete','maville',57, 'france','charge de mission','developpement tres difficile','img/monumage.gif','CDD','09/2000','03/2006','vraiment tres difficile la vie de developpeur','EJB, servlets, Jsp, UML, merise','Eclipse, powerAMC','vraimmennt tres difficile','aujourd\'hui'); $exp2->displayExp();
vous avez pas une idéee pour pouvoir avoir deux constructeur dans mon objetFatal error: Cannot redeclare experience::experience() in E:\WEB\fksite\class\experience.php on line 44
merci
wdionysos
rajout : precision, j'ai aussi essayer avec __construct() mais le resultat est le meme
wdio
Partager