Unexpected '$this' (T_VARIABLE)
Midix021
Messages postés
1
Date d'inscription
Statut
Membre
Dernière intervention
-
jordane45 Messages postés 38486 Date d'inscription Statut Modérateur Dernière intervention -
jordane45 Messages postés 38486 Date d'inscription Statut Modérateur Dernière intervention -
<?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
- No server is available to handle this request. - Forum Réseaux sociaux
- 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(); }