fork download
  1. <?php
  2. class Database {
  3. public $host;
  4. public $dbname;
  5. public $username;
  6. public $password;
  7. public $db;
  8. public function __construct() {
  9. $host = $this->host = "...";
  10. $dbname = $this->dbname = "...";
  11. $username = $this->username = "...";
  12. $password = $this->password = "...";
  13. try{
  14. $this->db = new PDO ("mysql:host=$host;dbname=$dbname", $username, $password);
  15. $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  16. $this->db->query('SET NAMES "utf8"');
  17. }
  18. catch (PDOException $e) {
  19. $e->getMessage();
  20. }
  21. }
  22. }
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Standard output is empty