SHARE
TWEET

Untitled

a guest Aug 18th, 2018 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. interface IConnectInfo
  3. {
  4.     const HOST ="localhost";
  5.     const UNAME ="phpWorker";
  6.     const DBNAME = "dpPatt";
  7.     const PW ="easyWay";
  8.     function testConnection();
  9. }
  10. ?>
  11.    
  12. <?php
  13. include_once('IConnectInfoMethod.php');
  14. class ConSQL implements IConnectInfo
  15. {
  16.     //Passing values using scope resolution operator
  17.     private $server=IConnectInfo::HOST;
  18.     private $currentDB= IConnectInfo::DBNAME;
  19.     private $user= IConnectInfo::UNAME;
  20.     private $pass= IConnectInfo::PW;
  21.     public function testConnection()
  22.     {
  23.         $hookup=new mysqli($this->server, $this->user, $this->pass, $this->currentDB);
  24.         if (mysqli_connect_error())
  25.         {
  26.             die('bad mojo');
  27.         }
  28.         print "You're hooked up Ace! <br />" . $hookup->host_info;
  29.         $hookup->close();
  30.    }
  31. }
  32.  
  33. $useConstant = new ConSQL();
  34. $useConstant->testConnection();
  35. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top