Guest User

Untitled

a guest
Aug 18th, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  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. ?>
Add Comment
Please, Sign In to add comment