Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DB
- {
- var $connection;
- function __construct ($localhost = false, $user = false, $pass = false, $db_name = false)
- {
- if ($this->connection)
- {
- return $this->connection;
- }
- else
- {
- $this->connection = mysql_connect('localhost', 'test_user', '') && mysql_select_db ('test_db') or die ('Cannot connect to MySQL: ' . mysql_error());
- mysql_query ("SET NAMES 'utf8'");
- return $this->connection;
- }
- }
- }
- $a = new DB;
- print_r ($a);
Add Comment
Please, Sign In to add comment