Unexpected '$this' (T_VARIABLE)

Fermé
Midix021 Messages postés 1 Date d'inscription samedi 13 janvier 2018 Statut Membre Dernière intervention 13 janvier 2018 - 13 janv. 2018 à 20:49
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 - 13 janv. 2018 à 22:59
<?php


class bd{

    private $hostname;
    private $dbname;
    private $username;
    private $password;
    private $option = array(
                                PDO::ATTR_PERSISTENT =>true ,
                                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
                             ); 


   protected $bdd;

   public function __construct()
   {
    $ini = parse_ini_file('Parameter/paraBD.ini')
    $this->$hostname = $ini['hostname'];
    $this->$dbname = $ini['databaseName'];
    $this->$username = $ini['username'];
    $this->$password = $ini['password'];
    connection();
   }

   public function connection()
   {
        $dsn = 'mysql:host='. $this->$hostname .';dbname='. $this->$dbname;
        $this->$bdd = new PDO($dsn, $this->$username, $this->$password, $this->$option);  
   }
}  

2 réponses

NHenry Messages postés 15113 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 22 avril 2024 331
13 janv. 2018 à 21:29
; manquant
0
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 4 650
13 janv. 2018 à 22:59
Bonjour,

En plus du point-virgule manquant .. tu as aussi des $ en trop.

 public function __construct()
   {
    $ini = parse_ini_file('Parameter/paraBD.ini');
    $this->hostname = $ini['hostname'];
    $this->dbname = $ini['databaseName'];
    $this->username = $ini['username'];
    $this->password = $ini['password'];
    connection();
   }
0