Instance de classe - Probleme de constructeur
Bonjour, je débute en PHP et rencontre un soucis sans pour autant avoir de message d'erreur.
Plutôt qu'un long discour :
// MA CLASSE :
Code:
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
| <?php
class plant {
// attributs
public $id;
public $nom;
public $taille;
public $variete;
public $age;
public $buds;
public $buds_poid;
public $croissance;
public $floraison;
public $resist_humidite;
public $resist_maladie;
public $thc;
//methodes
public function _construct(string $nom, string $variete, int $croissance, int $floraison, int $res_humide, int $res_malade, int $thc){
$this->nom = $nom;
$this->variete = $variete;
$this->croissance = $croissance;
$this->floraison = $floraison;
$this->resist_humidite = $res_humide;
$this->resist_maladie = $res_malade;
$this->thc = $thc;
return $this;
} |
// LA PAGE OU J'INSTANCIE CETTE MEME CLASSE :
Code:
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
|
<?php
// AUTOLOAD
function chargerClasse($classname)
{
require $classname.'.class.php';
}
spl_autoload_register('chargerClasse');
include "templates\header.htm";
echo '<a href="index.php">Retour</a>';
$planto = new plant('poilux', 'Indica', 3 ,3 ,3 ,3 ,3);
Echo $planto->nom;
Echo $planto->variete;
Echo $planto->thc;
Echo $planto->floraison;
Echo $planto->resist_maladie;
Echo $planto->croissance; |
(J'ai un peu tronqué le tout)
echo et print ne renvoient rien et J'obtiens une page vide à l'arrivé.