Unexpected '$this' (T_VARIABLE)
                    
        
     
             
                    Midix021
    
        
    
                    Messages postés
            
                
     
             
            1
        
            
                                    Statut
            Membre
                    
                -
                                     
jordane45 Messages postés 40050 Statut Modérateur -
        jordane45 Messages postés 40050 Statut Modérateur -
<?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);  
   }
}  
        A voir également:         
- Unexpected '$this' (T_VARIABLE)
 - Hijack this - Télécharger - Antivirus & Antimalwares
 - This is the mail system at host ✓ - Forum Mail
 - Cannot display this video mode - Forum Ecran
 - No compatible source was found for this media - Forum Mozilla Firefox
 - This windows build is not supported by this playbook ✓ - Forum Windows 10
 
2 réponses
                        
                    Bonjour,
En plus du point-virgule manquant .. tu as aussi des $ en trop.
 
 
    
                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();
   }