Guest User

Untitled

a guest
Apr 12th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <?php
  2.  
  3. class DB
  4. {
  5. var $connection;
  6. function __construct ($localhost = false, $user = false, $pass = false, $db_name = false)
  7. {
  8. if ($this->connection)
  9. {
  10. return $this->connection;
  11. }
  12. else
  13. {
  14. $this->connection = mysql_connect('localhost', 'test_user', '') && mysql_select_db ('test_db') or die ('Cannot connect to MySQL: ' . mysql_error());
  15. mysql_query ("SET NAMES 'utf8'");
  16. return $this->connection;
  17. }
  18. }
  19. }
  20.  
  21. $a = new DB;
  22. print_r ($a);
Add Comment
Please, Sign In to add comment